I'm using Jaydata with it's Indexeddbprovider, I've a problem in adding scenario.
When there are multiple adds, just the first one works!
$data.Entity.extend("Person", {
Id: { type: "int", key: true, computed: false },
Task: { type: String, required: true, maxLength: 200 },
DueDate: { type: Date },
Completed: { type: Boolean },
University: { type: "int"},
Degree: { type: "int" }
});
$data.EntityContext.extend("ClientDatabase", {
People: { type: $data.EntitySet, elementType: Person }
});
var db = new ClientDatabase({
provider: 'indexedDb', databaseName: 'ClientDB', version: 1
});
var newEntity = {
Id: 1,
Task: 'task1',
DueDate: new Date(),
Completed: false,
University: 1,
Degree: 1
};
var newEntity2 = {
Id: 4,
Task: 'task4',
DueDate: new Date(),
Completed: false,
University: 4
Degree: 4
};
add(db, newEntity, entity1AddedSuccessfully);
function entity1AddedSuccessfully(){
add(db, newEntity2);
}
function add(db, entity, callback){
db.onReady({
success: function () {
db["_People"].add(entity);
db.saveChanges(function () {
if (callback !== undefined) {
callback(entity);
}
});
}
});
}
The problem is in this scenario, newEntity is just added to ClientDB and there is no newEntity2!
Any help would be appreciated.