问题描述
我正在将Backand BaaS用于我的离子应用程序.我的模型包含两个表:1.用户2.旅行
I am using Backand BaaS for my ionic app. My model consists of two tables:1. Users2. Trips
用户"和旅行"之间已经建立了一对多的关系.
A one-to-many relationship has been established between 'Users' and 'Trips'.
用户"具有一个收集字段,该收集字段是"Trips"的集合,而"Trips"具有一个所有者字段,该所有者字段是一个用户"的对象.
'Users' has a collection field that is a collection of 'Trips' and 'Trips' has a owner field that is an object of 'Users'.
创建对象的正确方法是什么,以便在创建对象时将正确的所有者(用户"对象)分配给"Trips"收集字段?
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 ?
推荐答案
发布新Trip时,请将其用于Trip对象
When POSTing a new Trip use this for the Trip Object
{
tripName:"asdf"
owner:1
}
在users对象中,它看起来像这样
In the users object it will look like this
{
id:1
fName:"david"
trips:[{__metadata: {id: 1}, tripName: "asdf"}]
}
这篇关于使用Backand BaaS时如何创建具有关系的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!