Check out the code snippets on JayData main page - look for "Relations".
I explain the basics, to make it clear with an up-to-date example:
$data.Entity.extend("Todo", {
Id: { type: "int", key: true, computed: true },
Task: { type: String, required: true, maxLength: 200 },
Person: { type: "Person", required: true, inverseProperty: "Todos"}
});
$data.Entity.extend("Person", {
Id: { type: "int", key: true, computed: true },
Name: { type: String, required: true, maxLength: 200 },
Todos: { type: Array, elementType: Todo, inverseProperty: "Person" }
});
$data.EntityContext.extend("TodoDatabase", {
Todos: { type: $data.EntitySet, elementType: Todo },
People: { type: $data.EntitySet, elementType: Person }
});
Todo Entity: We define the Person navigation property as a reference field, its type is "Person" - will be declared later. The inverseProperty must be set in order let JayData to help you to find the other side of the relationship.
Person Entity: One person can have multiple todos, so we define a collection of Todos. The elementType defines the type of the items in the collection. You need the inverseProperty here, too.
Note: The navigationProperty was valid in early versions of JayData, it was renamed to inverseProperty after the feedback from the developer community. Unfortunately, this page wasn't updated...until now... Thank you for asking, let us know if yous still find confusing info, we really want to have the documentation clear and up-to-date, but we have many contents, we can do it only with your feedback. Thank you!