Table.defineClass()
Syntax
table.defineClass(structure)Parameters
Return Value
Remarks
Sample
var db = new Dexie("FriendsDB");
// The stores() method just specify primary key and indexes
db.version(1).stores({
friends: "++id,name,shoeSize"
});
// When using defineClass(), you may specify
// non-indexed properties as well and their types
var Friend = db.friends.defineClass ({
name: String,
shoeSize: Number,
cars: [Car],
address: {
street: String,
city: String,
country: String
}
});
function Car() {}
Friend.prototype.log = function () {
console.log(JSON.stringify(this));
}
db.open();
db.friends.where("name").startsWithIgnoreCase("d").each(function(friend) {
friend.log();
}).catch(function (e) {
console.error(e);
});