Naved Mir
Naved Mir

Reputation: 97

Can I store a relational table in memory and query it in node.js?

when a node js program starts, i will read data from a table and store it in nodejs global memory.Once this is loaded, in the program, when traffic comes, select a row from the loaded table based on some parameters.

Upvotes: 1

Views: 2991

Answers (1)

Charlie
Charlie

Reputation: 23778

SQL Lite is an in-process database which can write either to a disk file or to memory.

const sqlite3 = require('sqlite3').verbose();
let db = new sqlite3.Database(':memory:');


let db = new sqlite3.Database(':memory:', (err) => {
  if (err) {
    return console.error(err.message);
  }
  console.log('Connected to the in-memory SQlite database.');
});

Now you can serialize queries and use it as an in-memory database.

Upvotes: 4

Related Questions