sagitarius
v0.0.3
Published
Fast, minimal and modern NeDB ODM for Node.
Downloads
112
Readme
Introduction
Minimal, easy to use, fast Object Document Mapping(ODM) library for NeDB. Supports type-checking and schema validation.
Installation
npm install sagitarius
yarn add sagitarius
pnpm add sagitarius
Quick Start
Create and initialize the model:
import { Model } from "sagitarius";
class User extends BaseModel{
constructor(doc){
super(doc)
Object.assign(this, doc);
}
}
Define a schema to be able to perform validation:
User.define("User", {
username: String,
age: Number,
});
Create a new user:
const user = new User({ username: "Rednexie", age: 18 });
await user.save()
Update user properties:
user.age = 19;
await user.save();
API Reference
Instance Methods
async interface.save() Creates a new instance of the model with the provided document.
async interface.delete() Deletes the document from the database.
async interface.toJSON() Converts the document from the database to a JavaScript Object.
async interface.validate() Checks the datatypes and properties of the document. Returns true if valid, false if not.