Simple ORM for SQLite with decorators and TypeScript interfaces


Keywords
sqlite, orm, typescript-decorators
License
MIT
Install
npm install liteorm@0.9.5

Documentation

liteorm

A simple wrapper for sqlite; with typings based on TypeScript decorators and reflect-metadata. With async eventemitter (emittery). Focusing on JSON, Date, and MongoDB interop.

Also, support multiple SQLite databases, with cloned schemas or different schemas.

Usage

For example, please see /tests/suites

Querying data

To query, you have to supply condition { 'a.b': 'c' }, and optional field selector ['a'] or { 'a': 'b' } (a AS b). If no field is supplied, all fields will be selected.

JSON support

JSON querying is supported via JSON1 extension. I made it easy to query using dot notation, just like MongoDB.

Joining aka chain()

Joining (left and inner) is implemented through chain() method. The row name will now be table__row (in order not to interfere with dot notation), which still support JSON and Date conversion.

Installation

npm i liteorm

Caveats

  • Type Number by default is associated with INTEGER. To change it to FLOAT, use
@prop({type: 'float'}) f!: number;
  • BLOB is associated with Type ArrayBuffer.
@prop() data!: ArrayBuffer;
  • references, i.e. Foreign Key, is currently implemented at CREATE TABLE only. Joins (chaining) still has to be done manually.