meanair-model
v0.6.5-beta.1
Published
Opinionated common interface for declaring schemas and accessing data
Downloads
27
Readme
meanair (pronouced "MEAN-er" or "MEAN-air") is a framework for building + testing node.js apps.
meanair-model
Run it!
npm test
Quick overview
model
is mostly about enforcing a consistent interface for defining
defining schemas and data access agnostic of underlying persistent store.
Philosophically inspired by the (MS .net) Repository Pattern in which logic accesses pure data objects (via the Data Access Layer) without known about underlying persistance implementations.
Although this library is intended for meanair apps, it has no dependencies and could be used stand alone in any node app.
Glossary & acronyms
DA or DataAccessor classes - e.g. mongooseDA
- implement a
common interface for data access for a schema to a specific underlying
store.
DAL or DataAccessLayer is the set of DAs for Schemas available to an app.
/lib
DataAccess
** Common Interface **
getById(id, opts, cb) {}
getByQuery(query, opts, cb) {}
getAll(opts, cb) {}
getManyByQuery(query, opts, cb) {}
getManyById(ids, opts, cb) {}
searchByRegex(term, matchOn, opts, cb) {}
aggregate(chain, cb) {}
updateUnset(id, names, cb) {}
updateSet(id, fields, cb) {}
updateSetBulk(updates, cb) {}
create(o, cb) {}
delete(o, cb) {}
bulkOperation(inserts, updates, deletes, cb) {}
```
*Lots to say about why this interface was chosen at some point.*
<!-- Updates have to explicitly set which attribute is being updated.
This is very helpful where underlying collections may be represented
with different schemas or partial schemas across multiple apps hitting
the same database.
-->