node.js - Running Knex queries taking longer in files vs REPL -


I am trying to straighten any data into a database:

  / / Seeds js var Knex = Required ("knex"); Var database = requirement (". / Config"). Database; Var knex = Knex.initialize (database); Knex ("users") Insert ({first_name: "John", last_name: "doe"}) Exec (function (error, id) {console.log ("full", id);}); // Returns [1]   

My problem is that if I put it in a file and run it using node seed. Which Console.log Then it waits for a long time before returning a shell prompt (approximately 20 seconds) to do this in REPL so that the result is instantaneous.

Is there any reason that my code will wait 20 seconds before I show it to the command prompt again if I open it and run it to run in RPL?

By default node will not give you back the console unless the script is completely completely done. , While node repl inside because it returns the copy soon because the last line stops blocking.

In the repl you actually focus before printing console.log, while with the script it has to wait for the stuff to stop, you can call it process.exit (0) can move after adding console.log.

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -