The Expand module allows a Model's property to be filled with connected data - read from the same or another Database. In SQL this could be achieved with JOINs.
An Expand statement can be described as follows:
$expand
)property
)database
)foreign
)property
).Below are some example query strings utilizing the Expand module
Schema:
$expand=property/database/foreign
Example:
$expand=person/contacts/email
Schema:
$expand=property1/database1/foreign1/-/property2/database2/foreign2
Example:
$expand=person/contacts/email/-/book/book/isbn_10
Schema:
filter-property=filter-value&$expand=property/database/foreign
$expand=property/database/foreign&filter-property=filter-value
Example:
title=The Hobbit&$expand=person/contacts/email
$expand=person/contacts/email&title=The Hobbit
More about filtering.
It is possible to define a different property to be filled with the expanded Document(s). This prevents the original property
from being overwritten.
Such Expand statements are slightly different:
$expand
)database
)foreign
)property
)as
.Schema:
$expand=property/database/foreign/as
Example:
$expand=person/contacts/email/contact
Per default Documents are only resolved as a one-to-one relationship. To avoid cases where a Document has a collection of expanded Documents and others have a single connected Document, one-to-many relationships have to be configured explicitly. This is achieved through adding an asterisk ("*") to the local property key.
Schema:
$expand=property*/database/foreign
$expand=property*/database/foreign/as
Example:
$expand=person*/contacts/email
$expand=person*/contacts/email/contact