我有下面的代码,我对如何访问领域linkingObjects感到困惑。 他们是一些自动附加的数据吗? 我只是不明白它的实际作用?因为我无法获取它的价值。
name: 'Person',
properties: {
name:'string',
dogs: 'Dog[]'
}
}
const DogSchema = {
name:'Dog',
properties: {
name:'string',
// No shorthand syntax for linkingObjects properties
owners: {type: 'linkingObjects', objectType: 'Person', property: 'dogs'}
}
}
schema: [DogSchema, PersonSchema]
}).then(realm => {
realm.write(() => {
const barker=realm.create('Dog',{
name:'barker'
})
const ash=realm.create('Person',{
name:'ash',
dogs:[barker]
})
ash.dogs.push({name:'badDog'})
realm.objects("Person").map(person=>{
console.log(person )//no worker data
})
});
this.setState({ realm });