-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define relationship b/w two collections #4520
Comments
You don't have to specify the primary key |
I want to query But when I'm defining the above relationship and trying to open a realm instance I'm not receiving any data to my local db. |
ok, is there any error coming back in the sync logs? |
I'm not sure if this is the issue, but you should try this change in your article schema |
I think this is the error: "Failed to transform received changeset: Schema mismatch: Property 'article_meta' in class 'article' is of type Link on one side and type ObjectId on the other." |
It sounds like the relationship on the server side hasn't picked up the relationship properly and is interpreting the property as a simple object id. You should be able to turn on development mode on the server and change it, see https://docs.mongodb.com/realm/sync/configure-your-data-model/#view-and-fix-schema-errors |
Is it possible to make relationship b/w two collections which have different partition keys.If Yes how? What should be the approach if I want to sync two collections with different partition keys.
|
Each partition value will end up in a different Realm instance. Any relationships that you set up between the collections that fall into different Realm instances will be You can read up on how partitioning works in the docs: https://docs.mongodb.com/realm/sync/partitioning/. |
How Can I query with "IN" operator. I wanted to get filtered results on basis of some ObjectIds. How Can I achieve this? Query so far: |
@abhishekmatta999 As we strive to use github for bugs and feature requests only I would advise posting usage questions in our Forums for MongoDB Realm about sync in general and the SDK forums for specific SDK questions. |
@abhishekmatta999 this is not yet supported (tracked here) but you can use a workaround by writing out the long form as described here. |
Hey @abhishekmatta999, as @bmunkholm said above the Forums are the best place to get general help. This repository is only monitored by the engineers working on the Mobile Database. You're welcome to submit questions and bug reports here about the embedded database specifically. |
I want to query and get the article result and in article schema we have defined a key 'article_meta' which is and objectId. Now I want article result with all the properties with article_meta as an object fetched on the basis of (article.article_meta = articlemeta._id). But when I'm trying to open a realm, sync starts but there is no data in the local db but when I tried it without the defining any relationship it works.
`const articleMetaSchema = {
name: 'articlemeta',
properties: {
_id: 'objectId?',
catalog_id: 'objectId?',
content: 'objectId?',
createdAt: 'date?',
description: 'string?',
main_image_url: 'string?',
origin_type: 'string?',
pub_date: 'date?',
publication: 'objectId?',
sub_title: 'string?',
title: 'string?',
updatedAt: 'date?',
url: 'string?'
},
primaryKey: '_id'
}
const articleSchema = {
name: 'article',
properties: {
_id: 'objectId?',
active_search: 'bool?',
article_meta: 'articlemeta?',
catalog_id: 'objectId?',
content: 'objectId?',
createdAt: 'date?',
flagged: 'bool?',
owner_id: 'objectId?',
rating: 'int?',
read: 'bool?',
status: 'string?',
status_updated_at: 'date?',
updatedAt: 'date?'
},
primaryKey: '_id'
}
config = {
schema,
path: getDBPath(),
sync: {
user: app.currentUser,
partitionValue: '--value--',
error: (error) => {
console.log(error.name, error.message)
}
}
}
let realm = await Realm.open(config)
// query
`
The text was updated successfully, but these errors were encountered: