I'm building a very simple API with sails which handles participants
and teams
. Teams might have several participants, so the API should accept multiple participants
IDs to create the relationships when creating a new team.
Participant model
attributes: {
name:{
type : 'string',
required : true
},
email : {
type : 'email',
required : true,
unique : true,
},
age : {
type : 'string'
}
}
Team model
attributes: {
name:{
type : 'string',
required : true
},
logo : {
type : 'string'
},
participants:{
model: 'participant'
}
}
I can create a team and save the relationship successfully to one participant passing the following JSON to the API:
{
"name" : "Best Team ever",
"logo" : "http://...."
"participants" : "546bc4136911426a093cb903"
}
But i'm having trouble to save the relationship to several participants, I've tried passing an array of IDs to the API but it doesn't save any relationship, either passing and object of IDs.
I would like to save the relationship to several participants on a single request.
Can i complete this behaviour with sails relationships and blueprints ? or I have to do it manually within the controller
Thanks in advance.
I'm using sails-mongo
just in case.