Licence
MIT
Version
0.1.0
Deps
0
Vulns
0
Weekly
0
adapter-fixture
Qe (Query envelope) enabled in-memory adapter.
This adapter stores, updates and retrieves records from a memory store. It is not intended for production. Its primary use is for development testing as a fixture without requiring a backend.
Usage
Pass a Qe and a callback to adapter.exec(qe, cb):
var adapter = require('mekanika-adapter-fixture');
adapter.exec( {do:'find',on:'users'}, fn );
// Callback receives (error, results)
Override default .id identifier field name using:
adapter.idField = '_id';
Supported features
All reserved Query do actions are supported:
- 'create'
- 'find'
- 'update'
- 'remove'
Supports .match and the following match operators:
- eq, neq, in, nin, all, lt, lte, gt, gte
Supports .populate:
- by field name:
{ 'friends':{} } - with Qe:
{ 'friends': {query:{on:'users'}} } - on foreign key:
{'friends': {key: 'users_id'} }
{
do:'find',
on:'posts',
populate:{
'comments': {
key:'cmt_id',
query: {select: ['body']}
}
}
}
Supported .update reserved operators:
- inc -
{update: [ {score: {inc: 5}} ]} - push -
{update: [ {tags: {push:['cool']} ]} - pull -
{update: [ {tags: [pull:'removeme']} ]} - unset -
{update: [ {tags: {unset:true}} ]}
Supports .limit, .select, .offset result filters:
{
do:'find',
on:'posts',
limit:5,
offset:10,
select:['-date']
}
Fixture Adapter uses .id as its identifier field.
License
MIT