0.21.9 • Published 4 years ago

lowdb-model v0.21.9

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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
0.21.9

4 years ago

0.21.8

4 years ago

0.21.7

4 years ago

0.21.6

4 years ago

0.21.5

4 years ago

0.21.4

4 years ago

0.21.3

4 years ago

0.21.2

4 years ago

0.21.1

4 years ago

0.21.0

4 years ago

0.20.11

4 years ago

0.20.10

4 years ago

0.20.9

4 years ago

0.20.8

4 years ago

0.20.7

4 years ago

0.20.6

4 years ago

0.20.5

4 years ago

0.20.4

4 years ago

0.20.2

4 years ago

0.20.1

4 years ago

0.20.0

4 years ago

0.19.5

4 years ago

0.19.4

4 years ago

0.19.3

4 years ago

0.19.2

4 years ago

0.19.1

4 years ago

0.19.0

4 years ago

0.18.5

4 years ago

0.18.4

4 years ago

0.18.3

4 years ago

0.18.2

4 years ago

0.18.1

5 years ago

0.18.0

5 years ago

0.17.3

5 years ago

0.17.2

5 years ago

0.17.0

5 years ago

0.16.3

5 years ago

0.16.2

5 years ago

0.16.1

5 years ago

0.16.0

5 years ago

0.15.4

5 years ago

0.15.3

5 years ago

0.15.2

5 years ago

0.15.1

5 years ago

0.15.0

5 years ago

0.14.0

5 years ago

0.13.1

5 years ago

0.13.0

5 years ago

0.12.0

5 years ago

0.11.1

5 years ago

0.11.0

5 years ago

0.10.2

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago