此代码来自官方示例,可以正常使用webSql,但我得到Uncaught TypeError:使用indexedDb提供程序输入错误。
这里有什么问题? (提供者包含在html中)
/* define a data model. */
$data.Entity.extend("$org.types.Department", {
Id: { type: "int", key: true, computed: true },
Name: { type: "string", required: true },
Address: { type: "string" },
Employees: { type: "Array", elementType: "$org.types.Employee", inverseProperty: "Department" }
});
$data.Entity.extend("$org.types.Employee", {
Id: { type: "int", key: true, computed: true },
FirstName: { type: "string", required: true },
LastName: { type: "string", required: true },
Department: { type: "$org.types.Department", inverseProperty:"Employees"}
});
$data.EntityContext.extend("$org.types.OrgContext", {
Department: { type: $data.EntitySet, elementType: $org.types.Department },
Employee: { type: $data.EntitySet, elementType: $org.types.Employee }
});
//Now that the model is defined, instantiate the context (ie. set up the connection or the local database):
$org.context = new $org.types.OrgContext({ name: "indexedDb", databaseName: "OrgDB" });
$org.context.onReady(function() {
//Create new ones...
var emp = new $org.types.Employee({ FirstName: 'John', LastName: 'Doe' });
$org.context.Employee.add(emp);
$org.context.saveChanges();
});
UPD: 现在我看到这个错误在indexedDbProvider.min.js
中答案 0 :(得分:0)
这适用于最新的Chrome。确保以正确的顺序加载模块(JayData库必须是第一个,而不是加载提供者/模块)。