Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
})
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;
}
static getContainer(name) {
const adapter = new MyAdapter({});
const store = new Container();
store.registerAdapter('mock', adapter, { 'default': true });
return store;
}