-
Notifications
You must be signed in to change notification settings - Fork 70
awe v8 api
awe.media edited this page Oct 12, 2016
·
1 revision
It's a simple datastore template that makes it easy to store, manage and extend collections of javascript objects in a consistent way.
Trust me, it's funkier than that sounds! 8)
Each datastore by default is designed to support a standard set of "8 verbs".
- search
- list
- add
- view
- edit
- update
- delete
- report
Through the magical process of simplification this translates in a subset of "6 implemented methods".
- list
- add
- view
- update
- delete
- report
search and edit are simply UIs that drive one of these 6 methods.
e.g. edit -> update or search -> list
There are also 3 utility methods:
- error_handler
- get_data
- toString
In simple js mode a method call either returns undefined for an error or either an object or an array of 0 or more objects.
var my_datastore = new awe_v8();
console.log("add an object (return new id)");
my_datastore.add({
id: "test",
some_data: "blah"
});
console.log("add several objects (return new ids)");
my_datastore.add([
{
id: "test2",
some_data: "blahdeblah"
},
{
new_param: 99,
id: "test3",
some_data: "hrmok"
},
]);
console.log("list all objects (return all objects)");
my_datastore.list();
console.log("list all objects (return all objects in SOAPjr)");
my_datastore.list({}, { output_format:"soapjr" });
console.log("view an object (return one object)");
my_datastore.view("test"); // simple
my_datastore.view({ id: "test" }); // clear
my_datastore.view({ id: "test" }, { output_format:"js" }); // explicit
console.log("update an object (return updated fields)");
my_datastore.update({
data: {
new_param: 34,
some_data: "new_data",
},
where: {
id: "test",
}
});
console.log("update 2 objects (return updated fields)");
my_datastore.update({
data: {
new_param: 34,
some_data: "new_data",
},
where: {
id: ["test","another_test"],
}
});
console.log("update 3 objects (return updated fields)");
my_datastore.update([
{
data: {
new_param: 34,
some_data: "new_data",
},
where: {
id: "test",
}
},
{
data: {
new_param: 35,
some_data: "more_new_data",
},
where: {
id: ["test","another_test"],
}
},
]);
console.log("list fuzzy matches (return roughly matching objects)");
my_datastore.list({ id: "test" }, { limit: 10 });
console.log("list exact matches (return exactly matching objects)");
my_datastore.list({ exact: { id: "test2" } });
console.log("delete an object (return deleted ids)");
my_datastore.delete({ id: "test2" });
console.log("delete multiple objects (return deleted ids)");
my_datastore.delete({ id: ["test1", "test2"] });
console.log("report overview info (return a summary)");
my_datastore.report();