choko
choko copied to clipboard
List references
Allow "list" reference type that would create an aditional endpoint e.g. rest/myType/some-item/myReferenceFieldName, so for e.g. if we have blog posts on path rest/blog/some-blog-post, we could have a list reference field "comments" so we could access this blog post comments as rest/blog/some-blog-post/comments.
#29 is related.
This is now possible after waterline integration, you can use the via
property to tell what field on the referenced type map to the current type. E.g.:
On a comment
type:
fields: {
post: {
type: 'reference',
reference: {
type: 'post'
}
}
}
On a post
type:
fields: {
comments: {
type: 'reference',
reference: {
type: 'comment',
via: 'post'
}
}
}
Then you can populate comments on post item with the populate()
method.
It still needs to have endpoints for getting referenced items via REST like this issue describes.
:+1: