title: SELECT query synchronous with nodejs and sqlite3
body: <p>I am new to nodejs and facing an issue with sqlite select query</p>
  
  <p>Below is my code. </p>
  
  <pre><code>function parse(topic, msg, name) {
  
      item = get_obj(tbl_name, handle, JSON.stringify(arg))
  
      // get item from database
      return [handle, arg, item, action];
  }
  
  
  function get_obj(tbl_name, handle, obj_str) {
  
      let dbname = "test.sql";
      let query, ret;
      let my_obj = {};
      let db = new sql.Database(dbname);
      let str = "'" + obj_str + "'";
      query = "SELECT handle from " + tbl_name + " where object=" + str;
      db.serialize(function(ret) {
      let ret1 = db.each(query, function(err, row, ret) {
          if (err) {
              console.log("No records found");
          } else {
              if (row.handle == handle) {
                  ret = JSON.parse(obj_str);
              }
          }
      });
      });
      }
  </code></pre>
  
  <p>I want my parse should wait till i am done with get_obj(). In current scenario my parse returns immediately. Any help is appreciated.  </p>