jaydata未捕获类型错误:indexedDb的类型错误



这段代码来自官方示例。它在webSql中运行良好,但在indexedDb提供程序中出现Unaught TypeError:Type错误。

这里怎么了?(提供者包含在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 中

这是在使用最新的Chrome。确保以正确的顺序加载模块(JayData库必须是第一个,然后才能加载提供程序/模块)。

相关内容

  • 没有找到相关文章

最新更新