@pxe/database
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Database

A local JSON database for Node.js

Installation

# NPM
npm i @pxe/database vlds 

# Yarn
yarn add @pxe/database vlds

Usage

import Database from "@pxe/database";
import types from "vlds";

// Create a new database 
const db = new Database("/path/to/db");

// For TS type checking 
type UserType = { id: string, password: string };

// Create a new collection
const User = db.collect<UserType>("users", {
    id: types.string,
    password: types.string
});

// Create a new user 
const user = new User({
    id: "t7348gun9vio",
    password: "38hbn0p0v"
});

// Save to database 
await user.save();

// Find user
const currentUser = User.findOne({
    id: "t7348gun9vio"
}); 
console.log(currentUser.data);

// Delete user
User.remove(currentUser.id);

// Remove the user collection
db.remove("users");

// Clear the database
db.clear();

Readme

Keywords

none

Package Sidebar

Install

npm i @pxe/database

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

7.06 kB

Total Files

5

Last publish

Collaborators

  • reve-node