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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -