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.
chain()
Joining aka 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 withINTEGER
. To change it toFLOAT
, use
@prop({type: 'float'}) f!: number;
-
BLOB
is associated with TypeArrayBuffer
.
@prop() data!: ArrayBuffer;
-
references
, i.e. Foreign Key, is currently implemented atCREATE TABLE
only. Joins (chaining) still has to be done manually.