Closed cayuu closed 9 years ago
Added in 0.4.0
: "populate" - currently in Experimental phase.
Question of whether (and if so how) to represent "foreign key" references in populate. As at 0.4.0
, populate looks as follows:
{ populate: { 'field' : $subqo } }
Given $subqo
is a regular Qo, the only foreign reference currently supported is the .resource
that the "field"
refers to. In this way users.likes
may refer to {resource: 'posts'}
. Great.
But that leaves a Qo consuming API determining the field/key to "join/associate" on either by:
id
), orBoth are viable options, but neither cover all use-cases. If the association key is known, it'd be nice to simply stick this in the Qo somewhere. A few options:
{associateOn: "assoicate_id"}
){resource: "users.associate_id"}
)meta
field (ie. arbitrary data)None are clear winners. Or perhaps modify the populate object to embed this:
{ populate: {
field: 'posts',
key: 'special_id_field',
query: {limit:20}
}
}
This seems like the best option.
Define a method to illustrate relational data.