0.2.14 • Published 4 years ago
json-db-orm v0.2.14
json-db-orm
A simple orm for node-json-db
Features
- supports node-json-db
- TypeScript and JavaScript support
- validator
- default value or function
Installation
npm install json-db-orm
npm install reflect-metadata
TypeScript Configuration
tsconfig.json
{ "emitDecoratorMetadata": true, "experimentalDecorators": true }
Basic Use
import {Store, Schema, ListSchema, AutoIncrementPrimary, Field} from 'json-db-orm';
Store.root = "" // your database path
@Schema("record")
class Record extends ListSchema{
@AutoIncrementPrimary()
id: number;
@Field({validate: (v: string)=>v.length <= 32})
message: string;
@Field({default: ()=>new Date().getTime()})
ts: number;
}
import {Schema, Store, Field, Primary, KeySchema} from 'json-db-orm';
import {dirname, join, resolve} from 'path';
Store.root = resolve(dirname(__filename), "data")
@Schema("user")
class User extends KeySchema{
@Primary()
id: number;
@Field()
name: string;
}
let user = new User();
user.id = 1;
user.name = "test"
user.save()
0.2.14
4 years ago
0.2.13
4 years ago
0.2.12
4 years ago
0.2.11
4 years ago
0.2.10
4 years ago
0.2.9
4 years ago
0.2.8
4 years ago
0.2.1
4 years ago
0.2.0
4 years ago
0.2.7
4 years ago
0.2.6
4 years ago
0.2.3
4 years ago
0.2.2
4 years ago
0.2.5
4 years ago
0.2.4
4 years ago
0.1.6
4 years ago
0.1.5
4 years ago
0.1.4
4 years ago
0.1.3
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago