@naturalcycles/db-lib
Lowest Common Denominator API to supported Databases
Supported databases
Features
- CommonDB, CommonDao, DBQuery
- Streaming (Node.js streams with backpressure)
- DBM / BM, validation, conversion (Joi-powered)
- Conventions
- String
ids
created
, updated
(unix timestamps)- Dates as ISO strings, e.g
2019-06-21
- Timestamps as unixtimestamps (seconds, not milliseconds; UTC)
- Complex objects as JSON serialized to string (DBM), converted to object (BM)
Concept
CommonDB is a low-level API (no high-level sugar-syntax). CommonDao is the opposite - a high-level
API (with convenience methods), built on top of CommonDB.
Concerns of CommonDB:
- Access to DB (all tables): CRUD (create, read, update, delete)
- Batch methods (cause they can be more optimal if implemented "natively")
- Querying
- Streaming
Concerns of CommonDao:
- Access to one DB Table ("kind")
- Transformation between DBM and BM, validation/conversion
- Auto-generating
id
, created
, updated
fields - Anonymization hook to be able to plug your implementation (privacy by design)
DEBUG namespaces
nc:db-lib:commondao
nc:db-lib:inmemorydb
Packaging
engines.node >= 10.13
: Latest Node.js LTSmain: dist/index.js
: commonjs, es2018types: dist/index.d.ts
: typescript types/src
folder with source *.ts
files included