closeio / flask-mongorest

Restful API framework wrapped around MongoEngine
Other
523 stars 88 forks source link

Saving Reference field along with object in POST request #118

Open anujism opened 5 years ago

anujism commented 5 years ago

I would like to save the reference field along with object in post request. Is there any way to do this?

For eg.

class User(db.Document):
    name = db.StringField(required=True, unique=True)

class Post(db.Document):
    # Some fields
    # ...
   author = db.ReferenceField(User)

Now, I want to create author while making a POST request: /post/ => { "author": { "name": "Test" }, ..other fields }