Closed hpelitebook745G2 closed 2 months ago
Please try setting the THROW_ON_GLOBAL_REALM
as outlined here, to figure out where you're using Realm
without an import:
import { flags } from "realm";
flags.THROW_ON_GLOBAL_REALM = true;
this is because you are using Realm without import check your Schemas and every part you use Realm.
for example you can define a schema in this way
export class PersonSchema extends Realm.Object<Person> {
name!: string
age?: number
static schema: Realm.ObjectSchema = {
name: 'Person',
properties: {
name: 'string',
age: 'int?',
},
}
}
but the right way is this
import Realm from 'realm' // <-- check yours imports
export class PersonSchema extends Realm.Object<Person> {
name!: string
age?: number
static schema: Realm.ObjectSchema = {
name: 'Person',
properties: {
name: 'string',
age: 'int?',
},
}
}
Thanks @buster95 , it worked. my problem when create new item use Realm.BSON for id without import Realm
How frequently does the bug occur?
Always
Description
I wanted to implement a Singleton class for Realm to ensure reusability throughout the application. Creating a separate instance for each component doesn't seem practical.
Stacktrace & log output
Can you reproduce the bug?
Always
Reproduction Steps
Versions:
Version
12.2.1
What services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
iOS 17 and Android 11.0
Build environment
Which debugger for React Native: Flipper Version 0.228.0 (50.0.0)
Cocoapods version
1.13.0