backand - How to make foreign key required? -


for model example given in documentation, noticed can create pet object without requiring owner. how specify in json owner required?

i see required switch fields tab, switch doesn't move when 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 json required field not supported foreign-key can workaround it. i'm backand , plan add in soon, meanwhile can either:

  1. add server side action in before create , before update events of "pets" object , check null value, , empty throw error. use following code:

    try{          if (userinput.items == null){              throw new error('must have owner');          }      }      catch(err){          throw new error('must have owner');      }

  1. other option access mysql database directly , set column not null. after done open pets object page , click "sync database". won't show indication in backand work.

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -