js-data-firebase
js-data-firebase copied to clipboard
Parent relationship not working as in HTTP Adapter
I'm not sure if it's on purpose. But I thought that by defining a resource as belonging to another resource using the property parent: true
It would behave as in the HTTP Adapter which mounts the endpoint relative to its parent.
If this is a planned feature that was forgotten, I can do a PR. If not, why ?
e.g:
var Comment = store.defineResource({
name: 'comment',
relations: {
belongsTo: {
post: {
parent: true,
localKey: 'postId',
localField: 'post'
}
}
}
});
Comment.find(5, { params: { postId: 4 } }); // GET /post/4/comment/5
I only ever imagined parent: true
to be something the http adapter uses.
I believe it would be a good feature for this adapter. Because the Firebase endpoints follows the REST pattern as the urls used in the HttpAdapter.
However, Firebase doesn't recommend to do a nested data structure. But I think it should be up to the developer.
Firebase doesn't recommend to do a nested data structure
I agree with that, as your Firebase database is just a large JSON tree, nested data requires that the client download inordinate amounts of data.
But I think it should be up to the developer.
Right. Would you be interested in adding support for this to js-data-firebase? I imagine you already have some code to handle this in your app.