1.0.5 • Published 2 years ago

kissdb v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

KissDB (ALPHA)

A JSON database with functions similar to mongoose / prisma. View more examples here


Basics

import KissDB from "kissdb";

export const kissdb = new KissDB({
    path: `./data/`,
    /*
    http: {
        active: true/false,
        port: 1510,
        preload: (p) => {} // port
    }
    keys: ["string", "array", "for", "pika-id"]
    */
});

Models

// */*.ts
import { Model, $default } from "kissdb";

export interface UserProps {
    userId: string;
    createdAt: number;
}
export default userModel = new Model<UserProps>("USER" /* inserted data on create eg */, {
    userId: $default(),
    createdAt: Date.now()
});

Fetching, Updating, Creating Data

// */*.ts

import userModel from "path_to_model.ts";

// Create

userModel.create({
    userId: "hello_world",
    createdAt: Date.now()
})

// Finding

const f = userModel.find({
    where: {
        userId: "hello_world"
    }
}) // Finds all matches

const ff = userModel.findFirst({
    where: {
        userId: "hello_world"
    }
}) // Finds first matche


// Updating

const u = userModel.update({
    where: {
        userId: "hello_world"
    }, {
        userId: "updated_hello_world"
    }
})

// Remove Data

const r = userModel.remove({
    where: {
        userId: "updated_hello_world"
    }
})


// Delete Model

const d = userModel.delete();
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago