Lastly, in (6), we create a choose ready assertion after which run it with question.all()
, outputting the outcomes to the console:
$ node --experimental-sqlite physicists.mjs
[
{
id: 1,
name: 'Albert Einstein',
quote: "I believe in Spinoza's God"
},
{
id: 2,
name: 'Marie Curie',
quote: 'Nothing in life is to be feared, it is only to be understood'
},
{
id: 3,
name: 'Richard Feynman',
quote: 'Nobody understands quantum mechanics.'
}
]
If we wish to save the desk to disk, we will change the database parameter to a filename the place the info shall be saved:
const database = new DatabaseSync('myFile.db');
With that straightforward change, now we have a persistent mechanism for sharing information throughout completely different processes and applications. If we run our earlier instance with this configuration, we’ll see the myFilename.db
file on disk: