For the model example given in the documentation, I noticed that you can create a pet
object without requiring a owner
. How do I specify in the JSON that owner
is required?
I see the Required switch from the Fields tab, but the switch doesn't move when I click on it.
[
{
"name": "pets",
"fields": {
"name": {
"type": "string"
},
"owner": {
"object": "users"
}
}
},
{
"name": "users",
"fields": {
"email": {
"type": "string"
},
"firstName": {
"type": "string"
}
"pets": {
"collection": "pets",
"via": "owner"
}
}
}
]
Currently in the JSON the required field is not supported for foreign-key but you can workaround it. I'm from Backand and we actually plan to add it in soon, but meanwhile you can do either:
try{
if (userInput.items == null){
throw new Error('must have owner');
}
}
catch(err){
throw new Error('must have owner');
}