node-persist icon indicating copy to clipboard operation
node-persist copied to clipboard

Several instances of node-persist

Open Go00oglin opened this issue 1 year ago • 0 comments

Hi I was going to use the node-persist in different parts of single node.js application, assuming different folders for persisting. But it looks like the last Init becomes the single Init.

For example:

const storage1 = require('node-persist');
const storage2 = require('node-persist');

async function test() {
  await storage1.init({dir: "./p1" });
  await storage2.init({dir: "./p2" });
  storage1.setItem("1", "First");
  storage2.setItem("2", "Second");
}

test();

In this case, the p1 and p2 folder will be created, but both files are created in the p2 folder.

Go00oglin avatar Oct 21 '24 15:10 Go00oglin