Saving the records in jaydata- web sql database is successful. How do we retrieve the record(Todo) from the database including Location.
$data.Entity.extend("Location", {
City: { type: String },
Country: { type: String }
});
$data.Entity.extend("Todo", {
Id: { type: "int", key: true, computed: true },
Task: { type: String, required: true, maxLength: 200 },
DueDate: { type: Date },
Completed: { type: Boolean },
Location: { type: Location }
});
$data.EntityContext.extend("TodoDatabase", {
Todos: { type: $data.EntitySet, elementType: Todo }
});
Relationships are lazy-loaded by JayData. You can use the .include('NavigationPropertyName') operator, which performs a JOIN in WebSQL.
Example:
One other thing is needed to make this work: update entity context with the location entityset.
You can read more on JayData entity releationships here - JayData and relationships