-
Notifications
You must be signed in to change notification settings - Fork 77
Linked Resources #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ah, I didn't realize Reading http://www.js-data.io/v1.0.0-alpha-3-0/docs/relations I figured it out. app.factory('Listing', ['DS', function (DS) {
return DS.defineResource({
name: 'listing',
baseUrl: '/api/v1',
deserialize: function(name, data) {
return data.data.objects;
},
relations: {
belongsTo: {
seller: {
localField: 'seller',
localKey: 'sellerId'
}
}
}
});
}]);
app.factory('Seller', ['DS', function (DS) {
return DS.defineResource({
name: 'seller',
baseUrl: '/api/v1',
deserialize: function(name, data) {
return data.data.objects;
},
relations: {
hasMany: {
listing: {
localField: 'listings',
foreignKey: 'sellerId'
}
},
}
});
}]); |
This kind of question would be better asked on the mailing list |
thanks for letting me know! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I saw this issue regarding nested resources: #40
I'm trying to do something similar but just link resources instead.
If a single "listing" object looks like:
URL: http://nucraigslist.herokuapp.com/api/v1/listing/798128320234094/
EDIT: just wanted to add that I can easily change
"seller": "/api/v1/seller/10203068149729605/"
into a"seller_id": 10203068149729605
URL: http://nucraigslist.herokuapp.com/api/v1/seller/10203068149729605/
and I have two resources set up:
how can I link the listing and seller objects so if have the following code:
how can I get
listing.seller
to equal theSeller
object?The text was updated successfully, but these errors were encountered: