0.1.4 • Published 6 years ago

js-data-memory v0.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Codetree

npm Scrutinizer Build Scrutinizer Scrutinizer Coverage npm

js-data-memory

An in-memory adapter for the JSData Node.js ORM. Credits to JDobry.

Installation

npm install --save js-data js-data-memory

Usage

var MemoryAdapter = require('js-data-memory');

/*
 *  Create an instance of the adapter
 */
var adapter = new MemoryAdapter();

/*
 *  Register the adapter instance
 */
store.registerAdapter('memory', adapter, { default: true });

JSData Tutorial

Start with the JSData.

License

The MIT License (MIT)

Example

var jsData        = require('js-data');
var MemoryAdapter = require('js-data-memory');

/*
 *  Optional
 */
jsData.utils.Promise = require('bluebird');

var adapter = new MemoryAdapter();

var container = new jsData.Container({ mapperDefaults: { } });

container.registerAdapter('memory', adapter, { 'default': true });

container.defineMapper('users');

container
    .count('users')
    .then(function (data) {
        res.send(JSON.stringify(data));
    })
    .catch(function (error) {
        res.send('ERROR<br>' + JSON.stringify(error));
    });

container
    .create('users',{name: 'name', password: 'password'})
    .then(function (data) {
        res.send(JSON.stringify(data));
    })
    .catch(function (error) {
        res.send('ERROR<br>' + JSON.stringify(error));
    });


container
    .findAll('users',{where: { password: { '==': 'password'} } })
    .then(function (data) {
        res.send(JSON.stringify(data));
    })
    .catch(function (error) {
        res.send('ERROR<br>' + JSON.stringify(error));
    });

Contributing

First, look at the issues page to ensure your issue isn't already known. If it's not, you can create a new issue with a detailed description of what happened & how to reproduce the unexpected behavior.

If you decide to take on the challenge of fixing a known (or unknown) issue, you can do so by sending in a pull request from your own fork of the project. Once it has been tested and approved, it will be merged into the master branch of the repository.

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago