Hello,

what is angular best practice using nested REST resource endpoints with 
MongoDB many-to-many relations?

In my case a user may have many devices being assigned to it.

var UserSchema = new Schema({
    .....
    assignedDevices: [{
        type: Schema.ObjectId,
        ref: 'devices'
    }]
});


On the other hand a device may have assigned many users.
var DeviceSchema = new Schema({
    ....

    assignedUsers: [{
        type: Schema.ObjectId,
        ref: 'User'
    }]
});

How I have to structure my angular $resource factories to attach nested 
endpoints?
e.g.:
-GET device with deviceId: api/devices/:deviceId
-assign user with userId to device with deviceId:  
api/devices/:deviceId/user/:userId
...

-GET user with userId: api/userss/:userId
-assign device with deviceId to user with userId:  
api/users/:userId/device/:deviceId

How to keep this many-to-many DeviceSchema.assignedUser and 
UserSchema.assignedDevices relation in sync?
e.g. when removing a user it has also to be removed from all 
DeviceSchema.assignedUsers

Thanks in advance
Janusz
  


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to