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 need to save the desk to disk, we will change the database parameter to a filename the place the info will likely be saved:
- Advertisement -
const database = new DatabaseSync('myFile.db');
With that easy change, we have now a persistent mechanism for sharing knowledge throughout totally different processes and applications. If we run our earlier instance with this configuration, we are going to see the myFilename.db
file on disk: