16.3 C
New York
Sunday, September 29, 2024

Intro to Node’s built-in SQLite module



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:



Supply hyperlink

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles