Many document stores, Y U NO interface?
Work in progress; see TODO.
About
Minimalistic ODM for Node.js implementing the most fundamental operations (such as GET
/SET
/DEL
) on different kinds of "document(-ish)" stores using one unified API. Switching database should be a matter of changing a line of code.
To stick to this philosophy more advanced operations won't be supported in core, but node-document
can be used along with any 3rd-party drivers.
Document
The ODM.
- Class
new
create
get
set
del
exists
- Instance
save
destroy
fetch
validate
diff
clone
inspect
- Events
Storage
Unified interface for write/read data to/from differen kinds of storages/databases.
- Operations: Single + Bulk
get
set
del
exists
- Connect-on-demand: Auto-connect on first operation (operation queue)
- Adapters
- Events
Validator
Unified interface for validating data based on a custom JSON Schema.
- Operations:
validate
- Adapters
Differ
Unified interface for diffing objects to see changes between the two (additions/removals/edits).
- Operations:
diff
- Adapters
Installation
$ npm install node-document
Usage
Basic:
var Document = ; // Some storages of choice - install via NPM var Redis = ; // NOTE: $ npm install node-document-storage-redis var FileSystem = ; // NOTE: $ npm install node-document-storage-fs // A model var Post = Document'Post' 'redis://localhost:6379/app'; // ...or shortcut: var Post = Document('Post', 'redis://localhost:6379/app'); // A record var post = title: "Once upon a time"; // Save it post; // etc.})
More usage examples coming soon, unil then checkout the tests.
Test
Local tests:
$ make test
Remote tests:
$ make test-remote
Notes
This project is very much work-in-progress; the API will most probably change between the first couple of minor version numbers until it will be settled.
Credit
- Christian Landgren - input and feedback
License
Released under the MIT license.
Copyright (c) Jonas Grimfelt