I have a database setup with a couple of different objects. For example lets say I have an object called 'kids' and a related object called 'toys'. Toys has a 'kid' id field which references the kid. What I would like is that when I create a kid I can also send a list of toys and have it automatically add those toys.
I created an action in the After Create section, but whenever I check the 'userInput' variable my extra data isn't there ( I'm using the test function in the app ). Consider the following:
return $http ({
method: 'POST',
url: Backand.getApiUrl() + '/1/objects/kids/',
params: {
name: 'Add Kid',
parameters: {}
},
data: {
name: 'Jimmy',
toys: ['truck', 'car', 'crane', 'motorbike'],
}
});
and then in the callback
function backandCallback(userInput, dbRow, parameters, userProfile){
console.log(userInput);
for ( var i = 0; i < userInput.toys.length; i++ ){
var toy = userInput.toys[i];
//use $http POST method to create a toy which relates to the user
}
}
Whenever I examine the userInput variable all I get is a json object with 'name' in it. However I would expect 'toys' to also be there.
I did wonder if maybe I was taking the wrong approach, should I be making a call to the api to create a kid and then take the data from that and make multiple api calls to create each toy?
thanks for your help