3.1.0 • Published 6 months ago

db-local v3.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

A local database for small to medium projects, that uses schema standardization and JSON to store data.

Installation

npm install db-local
yarn add db-local

Example Usage

const dbLocal = require("db-local");
const { Schema } = new dbLocal({ path: "./databases" });

const Creators = Schema("Creators", {
  _id: { type: Number, required: true },
  name: { type: String, default: "Customer" }
});

const User = Schema("User", {
  _id: { type: Number, required: true },
  username: { type: String, default: "Customer" },
  bag: {
    weapons: Array
  }
});

Create, Search, Update and Remove data

const user = User.create({
  _id: 1,
  username: "Lennart",
  tag: "Lennart#123",
  bag: { weapons: ["bow", "katana"] }
}).save();

User.find(user => user.bag.weapons.length >= 2); // Array(1)
User.find({ _id: 1 }); // Array(1)
User.find(1); // Array(1)

// Ways to get only one document

User.findOne(1); // Object
User.findOne({ _id: 1, $limit 1 }); // Object

user.update({ username: "Roger" });
user.username = "Roger"; // same as above

user.save(); // Always run the "save" function after creating or editing a user

user.remove();
User.remove(user => user.bag.weapons.length >= 2);
User.remove({ _id: 1 });
User.remove(1);

Contributing


Before creating an issue, please ensure that it hasn't already been reported or suggested.

When submitting a new pull request, please make sure the code style/format used is the same as the one used in the original code.

License


Refer to the MIT file.

3.1.0

6 months ago

3.0.0

6 months ago

2.9.1

1 year ago

2.9.0

2 years ago

2.8.9

2 years ago

2.7.8

2 years ago

2.8.8

2 years ago

1.7.8

2 years ago

1.6.9

2 years ago

1.6.8

2 years ago

1.6.7

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.4.3

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.7

2 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago