How to create objects that have relationships when using Backand BaaS?

泪湿孤枕 提交于 2019-12-12 19:13:13

问题


I am using Backand BaaS for my ionic app. My model consists of two tables: 1. Users 2. Trips

A one-to-many relationship has been established between 'Users' and 'Trips'.

'Users' has a collection field that is a collection of 'Trips' and 'Trips' has a owner field that is an object of 'Users'.

What is the correct way to create an object so that upon creating I am assigning the correct owner ('Users' object) to 'Trips' collection field ?


回答1:


When POSTing a new Trip use this for the Trip Object

{
tripName:"asdf"
owner:1
}

In the users object it will look like this

{
id:1
fName:"david"
trips:[{__metadata: {id: 1}, tripName: "asdf"}]
}


来源:https://stackoverflow.com/questions/35927642/how-to-create-objects-that-have-relationships-when-using-backand-baas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!