lowdb-model v0.21.9
Lowdb-model
Lowdb-model is a library for you to write object models for amazing lowdb database. You may think of it as the sequelize or mongoose of lowdb.
This library does not replace lowdb; it is meant to be used in conjunction with it. Lowdb-model provides safety by making it easy to define validation and model relationships, but it leaves you free to use the flexibility of lowdb whenever you need it.
## ⚠️🚧 lowdb-model
is under construction.
Do not use it until version 1 comes out.
## Type Definitions for End Usage
This is the new intended user API for the time being.
interface FieldDefinitions = {
[modelProperty: string]: string | number | string[] | number[]
}
type ValidationFunction = (thing: string | number | string[] | number[]) => boolean;
interface Validations {
[modelProperty: string]: ValidationFunction;
}
interface RelationshipDefinitions {
hasOne?: string[];
hasMany?: string[];
belongsToOne?: string[];
belongsToMany?: string[];
}
interface CreateModelArgs {
name: {
singular: string;
plural: string;
},
model: FieldDefinitions,
validation?: Validations,
relationships?: RelationshipDefinitions
}
type CreateModel = (args: CreateModelArgs) => Model
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago