I'm using the linq2indexedDB wrapper to work with IndexedDB. I'm working in TypeScript but I don't think that's really relevant to the issue - it should just explain the slightly odd syntax. I create my DB and add a number of object stores and indices (code shortened to keep to the point):
var databaseDefinition = [{
version: config.version,
objectStores: [
{ name: "Regions", objectStoreOptions: { autoIncrement: false, keyPath: "ID" } },
{ name: "Countrys", objectStoreOptions: { autoIncrement: false, keyPath: "ID" } }
// etc.
],
indexes: [
{ objectStoreName: "Countrys", propertyName: "RegionID", indexOptions: { unique: true, multirow: false } }
// etc.
]
}];
This works, and by inspecting my db structure in chrome F12 tools I can see the expected objectStores. I then try a simple insert operation:
var region = serverData.Regions[0];
this.db.linq.from("Regions").insert(region, region.ID).then((args) => {
tracer.Trace("Insert success: " + args);
}, (args) => {
tracer.Trace("Insert failure: " + args);
});
This fails, but the args
object returned is undefined, so I have no idea of why. Can anyone explain what the issue might be and how I can go about tracing it?
EDIT (Removed additional code as it wasn't strictly relevant to the issue. Turning on logging, as described in Kristof's answer below, helped track down the issue, which is resolved in my own answer below).