Skip to content

Instantly share code, notes, and snippets.

@simon-tiger
Created July 2, 2020 14:47
Show Gist options
  • Save simon-tiger/775237bbede08763ee884206790ee4f0 to your computer and use it in GitHub Desktop.
Save simon-tiger/775237bbede08763ee884206790ee4f0 to your computer and use it in GitHub Desktop.
// First you have to install NeDB. For this, you can just use `npm install nedb`.
// To create a database, do this:
const Datastore = require("nedb");
const db = new Datastore("database.db");
// Then, to query it, do this:
db.find({ property: requiredValue }, (err, results) => {
// results will hold the result
});
// To insert an entry, do this:
db.insert(whateverObjectYouWant);
// Finally, to update it, do this:
db.find({ property: requiredValue }, { $set: { property: newValue } }, (err, results) => {
// this code will happen when it's done updating
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment