This feature is not available if you are using the built js version
For a faster development, we offer a NoSQL solution that requires no configuration. We recommend to use redis, mongoose or rethinkdb when your app is production-ready.
Change the path of your NoSQL with client.nosql.path().
client.nosql.path("./data");
Retrieve by cid.
Parameters:
collection: Stringcid: Integerclient.nosql.get("monsters", 3).then(function(data) {
console.log(data);
});
Insert, add or push a list of elements.
Parameters:
collection: Stringelements: Array or Objectclient.nosql.insert("monsters", [
{name: "sphinx", mythology: "greek", eyes: 2, sex: "f", hobbies: ["riddles","sitting","being a wonder"]},
{name: "hydra", mythology: "greek", eyes: 18, sex: "m", hobbies: ["coiling","terrorizing","growing"]},
{name: "huldra", mythology: "norse", eyes: 2, sex: "f", hobbies: ["luring","terrorizing"]},
{name: "cyclops", mythology: "greek", eyes: 1, sex: "m", hobbies: ["staring","terrorizing"]},
{name: "fenrir", mythology: "norse", eyes: 2, sex: "m", hobbies: ["growing","god-killing"]},
{name: "medusa", mythology: "greek", eyes: 2, sex: "f", hobbies: ["coiling","staring"]}
]).then(function() {
console.log("Inserted data.");
});
client.nosql.insert("monsters", {name: "HamoIzm", mythology: "amazigh", eyes: 2, sex: "m", hobbies: ["riddles","hunting"]}).then(function() {
console.log("Inserted data.");
});
List all elements in the collection.
Parameters:
collection: Stringclient.nosql.list("monsters").then(function(result) {
console.log(result);
});
Delete an item by cid.
Parameters:
collection: Stringcid: Integerclient.nosql.remove("monsters", 1).then(function() {
console.log("Removed cid 1.");
});
Replace the element with the same cid.
Parameters:
collection: Stringcid: Integerelements: Array or Objectclient.nosql.replace("monsters", 6, {car: "Ferrari"}).then(function() {
console.log("Replaced cid 6..");
client.nosql.get("monsters", 6).then(function(result) {
console.log(result);
});
});
Update an element, it will add un-existed key and replace existed. ($created and cid can't be changed)
Parameters:
collection: Stringcid: Integerelements: Array or Objectclient.nosql.update("monsters", 5, {eyes: 3, food:"waloo"}).then(function() {
console.log("Updated cid 5..");
client.nosql.get("monsters", 5).then(function(result) {
console.log(result);
});
});
Search using an object or operators.
Parameters:
collection: Stringelements: Array or Objectclient.nosql.where("monsters", {name: "sphinx"}).then(function(result) {
console.log(result);
});
client.nosql.where("monsters", "@eyes >= 2").then(function(result) {
console.log(result);
});
client.nosql.where("monsters", "(@eyes == 2 && @mythology == 'greek') || (@mythology == 'amazing')").then(function(result) {
console.log(result);
});