Skip to content

Instantly share code, notes, and snippets.

@cnandreu
Created February 21, 2015 22:27
Show Gist options
  • Save cnandreu/52807b2b11f136866360 to your computer and use it in GitHub Desktop.
Save cnandreu/52807b2b11f136866360 to your computer and use it in GitHub Desktop.
Code used in the "MobileFirst Platform v6.3 JSONStore CLI Installation" Youtube Video (https://www.youtube.com/watch?v=OndEumD9VMs&hd=1)
function wlCommonInit () {
var collectionName = 'people';
var collections = {
people : {
searchFields : {name: 'string', age: 'integer'}
}
};
var options = {
username : 'username',
password : '123'
};
WL.JSONStore.init(collections, options)
.then(function () {
return WL.JSONStore.get(collectionName).add({name: 'carlos', age: 10});
})
.then(function (numberOfDocumentsAdded) {
console.log('Added: ' + numberOfDocumentsAdded);
return WL.JSONStore.get(collectionName).findAll();
})
.then(function (findResults) {
console.log('Find results:' + JSON.stringify(findResults, null, ' '));
})
.fail(function (errorObject) {
console.log('Failure: ' + errorObject.toString());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment