Data scheme allows setting a default scheme for data records of DataStore. So in cases when you add an empty record to DataStore (data.add({})), the record will be populated with the values set by the scheme.
myDataStore.data.scheme({
name:"Unknown",
gender:"male",
age:25,
department: "Unknown"
});
//will add {name:"Unknown",gender:"male",age:25,department:"Unknown"} record
myDataStore.add({});
There are also 2 special keys you can use in a scheme:
myDataStore.data.scheme({
$init:function(obj){
obj.value = obj.name; // 'name' is the name of the column from the db
obj.text = obj.name;
}
});
myDataStore.data.scheme({
$update:function(obj){
obj.text = obj.name + " " + obj.number;
}
});