0.2.14 • Published 3 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
3 years ago
0.2.13
3 years ago
0.2.12
3 years ago
0.2.11
3 years ago
0.2.10
3 years ago
0.2.9
3 years ago
0.2.8
3 years ago
0.2.1
3 years ago
0.2.0
3 years ago
0.2.7
3 years ago
0.2.6
3 years ago
0.2.3
3 years ago
0.2.2
3 years ago
0.2.5
3 years ago
0.2.4
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago