我编写了这段代码以在 Chrome 中将 WebSQL 与 JayData 一起使用:
$data.Entity.extend("$org.types.Department",
{
Id: { type: "int", key: true, computed: true },
Name: { type: "string", required: true }
});
$data.EntityContext.extend("$org.types.OrgContext", {
Department: { type: $data.EntitySet, elementType: $org.types.Department }
});
$org.context = new $org.types.OrgContext({ name: "WebSQL", databaseName:"Organization",
dbCreation: $data.storageProviders.sqLite.DbCreationType.DropTableIfChanged
});
var department = new $org.types.Department({ Name: 'Department1' });
$org.context.Department.add(department);
$org.context.saveChanges();
但问题是,在 $org.context.Department.add(department); 行, “部门”未定义。我该怎么办?