Skip to content
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

Data Sync incomplete on collections that app does not insert #6346

Closed
AlecsFarias opened this issue Dec 28, 2023 · 2 comments
Closed

Data Sync incomplete on collections that app does not insert #6346

AlecsFarias opened this issue Dec 28, 2023 · 2 comments

Comments

@AlecsFarias
Copy link

AlecsFarias commented Dec 28, 2023

How frequently does the bug occur?

Always

Description

Hi, I am using realm on react native

The issue is that when I tried to query collections that I do not insert on app (users for example) the app does not sync the data for that collection and I cant query that.

Why isn't it syncing all collections that is declared on de realm context config ?

Real examples:

// Collection that has some inserts on app: //

type GenerateProps = {
title: string;
banner?: string;
text: string;
structs: string[];
sticked?: boolean;
urgent?: boolean;
};

export class News extends Realm.Object {
_id!: Realm.BSON.UUID;
title!: string;
banner!: string;
text!: string;
createdAt!: Date;
structs!: string[];
deleted!: boolean;

static generate({
title,
banner,
text,
createdBy,
structs,
sticked,
urgent,
}: GenerateProps) {
return {
_id: new Realm.BSON.ObjectID(),
title,
banner,
text,
createdBy: new Realm.BSON.ObjectID(createdBy),
createdAt: new Date(),
structs,
sticked,
urgent,
};
}

static schema: ObjectSchema = {
name: "News",

properties: {
  _id: "objectId",
  title: "string",
  banner: "string?",
  text: "string",
  createdAt: "date",
  structs: {
    type: "list",
    objectType: "objectId",
  },
  sticked: {
    type: "bool",
    default: false,
    indexed: true,
  },
  urgent: {
    type: "bool",
    default: false,
    indexed: true,
  },
  deleted: {
    type: "bool",
    default: false,
    indexed: true,
  },
},
primaryKey: "_id",

};
}

// Collection that has not any insert on app: //

export class Users extends Realm.Object {
_id!: Realm.BSON.UUID;
name!: string;
document!: string;
register!: string;
"__v": number;
createdAt!: Date;
email!: string;
fcmToken?: string;
updatedAt?: Date;

static schema: ObjectSchema = {
name: "Users",

properties: {
  _id: "objectId",
  name: "string",
  document: "string",
  register: "string",
  __v: "int",
  createdAt: "date",
  email: "string",
  fcmToken: "string?",
  updatedAt: "date",
},
primaryKey: "_id",

};
}

// realm context config: //

const realmAccessBehavior: Realm.OpenRealmBehaviorConfiguration = {
type: Realm.OpenRealmBehaviorType.OpenImmediately,
};

export const syncConfig: any = {
flexible: true,
newRealmFileBehavior: realmAccessBehavior,
existingRealmFileBehavior: realmAccessBehavior,
};

export const { RealmProvider, useRealm, useQuery, useObject } =
createRealmContext({
schema: [News, Users],
schemaVersion: 1,
});

// realm sync useEffect: //

useEffect(() => {
realm.subscriptions.update((mutableSubs, realm) => {
const news = realm.objects("News");
const users = realm.objects("Users");

  mutableSubs.add(news, { name: "news" });
  mutableSubs.add(users, { name: "users" });
});

}, [realm]);

Not including the appProvider and etc.. because I think it is standart.
Using Anonymous session on attlas

News Collection is working as normal but users has never synced any data from atlas

Is there any missing config ?

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

@realm/react: 0.6.2 realm: 12.5.0

What services are you using?

Atlas Device Sync

Are you using encryption?

No

Platform OS and version(s)

React Native 0.72.6, expo

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

@AlecsFarias AlecsFarias changed the title Data Sync incomplete on collection that app does not insert Data Sync incomplete on collections that app does not insert Jan 2, 2024
@kneth
Copy link
Contributor

kneth commented Jan 4, 2024

@AlecsFarias I don't see anything obviously wrong, and I wonder if your permissions are device sync compatible.

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Jan 4, 2024
@AlecsFarias
Copy link
Author

Hi again, yeah, the problem was permissions on db config. Thanks for helping!!

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jan 11, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants