How to use the js-data.Container function in js-data

To help you get started, we’ve selected a few js-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github js-data / js-data-http / build_examples / node / app.js View on Github external
var JSData = require('js-data')
// normally this would be "var HttpAdapter = require('js-data-http-node')"
var HttpAdapter = require('../../')

var adapter = new HttpAdapter()
var store = new JSData.Container()
store.registerAdapter('http', adapter, { default: true })
store.defineMapper('user')

store.find('user', 1).catch(function (err) {
  console.log(err)
})
github denouche / virtual-assistant / src / helpers / database / mongodb.js View on Github external
let adapter;
        if(this.adapter) {
            adapter = this.adapter;
        }
        else {
            adapter = new MongoDBAdapter({
              uri: this.dbUrl
            });
            if(this.dbUrl) {
                // Only keep adapter if the url is set, to avoid reloading on first configuration
                this.adapter = adapter;
            }
        }

        let store = new Container({
            mapperDefaults: {
                idAttribute: '_id'
            }
        });
        store.registerAdapter('mongodb', adapter, { 'default': true });
        return store;
    }
github denouche / virtual-assistant / src / helpers / database / mock.js View on Github external
static getContainer(name) {
        const adapter = new MyAdapter({});
        const store = new Container();
        store.registerAdapter('mock', adapter, { 'default': true });
        return store;
    }