How to run sync queries in knex [Node]

How to results in sync manner in knex db in node. http://knexjs.org/#Promises-then

knex.select('*').from('users').where({name: 'Tim'})
  .then(function(id) {
    console.log('Inserted Account ' + id);
  })

i want something like this

knex.select('*').from('users').where({name: 'Tim'})
  .sync().then(function(id) {
    console.log('Inserted Account ' + id);
  }); // code should not continue to run until completing then function

or

how to make async lib to run multiple parallel tasks and return results in sync code. like below or something like that

               var results=async.sync().parallel([
                    task1,task2
                ],function(err, res){
                    results=res;
                }); // anything like var results or sync()
                console.log(results);   

I would question your need to run things in "sync mode". There is likely some flow control you can establish, and at worst you could be severely impacting your NodeJS server. Due to NodeJS's single-threaded architecture, what you are suggesting is to have all other events/users wait until the current action calls the DB and returns. This is not a good use of NodeJS.

From what I can tell from your question, something like async.parallel should work for you.

async.parallel({
  queryone: function( parCb ){
    var query = knex('users').select().where( 'name', 'Tim' );
    query.exec( function(err, results ) {
      parCb( err, results );
    } );
  },
  querytwo: function( parCb ){
    var query = knex('otherTable').select().where( 'name', 'Tim' );
    query.exec( function(err, results ) {
      parCb( err, results );
    } );
  },
},
function(err, results) {
  //Results are all ready, containing the results of two different queries
  console.log( 'Results for queryone: ' + JSON.stringify( results.queryone ) );
  console.log( 'Results for querytwo: ' + JSON.stringify( results.querytwo ) );
});

Here, when you reach the function(err,results) callback, results is filled with the data from the two queries, executing in parallel. All without completely blocking your other events.