2.0.5 • Published 3 years ago

ts-json-db v2.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

ts-json-db

A Node.js database using JSON file as storage. The result of requests are typed!

It's a wrapper around node-json-db which does the main job about the "database". This package is inspired by RESTyped and its autocomplete and type checks.

Demo

npm Downloads

Installation

Add ts-json-db to your existing Node.js project.

npm install ts-json-db

Usage

import TypedJsonDB, { ContentBase, Dictionary } from "ts-json-db";

interface Restaurant {
    name: string
    chef: string,
    memberCount: number,
    turnOver: number
}

interface Login {
    username: string,
    password: string
};

interface ContentDef extends ContentBase {
    paths: {
        '/login': {
            entryType: "single",
            valueType: Login
        },
        '/restaurants': {
            entryType: "array",
            valueType: Restaurant
        },
        '/teams': {
            entryType: "dictionary",
            valueType: string
        }
    }
}

let db = new TypedJsonDB<ContentDef>("config.json");
let result = db.get("/login");

console.log(result);

You can see in the example folder to find usage examples.

2.0.5

3 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.1

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.0.1

4 years ago

1.2.1

4 years ago

1.0.0

4 years ago