User = Backbone.RelationalModel.extend({
relations: [{
key: 'friends',
collectionType: 'User',
reverseRelation: {
key: 'user',
reference_id: 'user_id'
}
}]
});
- Fetch Relation
user = new User({id: 1})
user.fetchRelated('friends', options) # like backbone
- Get Relation
user.getRelation('friends')
- Set Relation
user.setRelation('friends', obj)
- Trigger when success
user.on('add:friends', function() {})
- Use update method when you only want pass specific params
user.update({status: 'online'})