Skip to content

mekanika/adapter-fixture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published