"realm.objects()" will return an number
See original GitHub issueGoals
Get all results
Expected Results
realm.objects('Video')
should return an array
Actual Results
A number is returned, almost half, looks like not the count of the result.
Steps to Reproduce
Code Sample
var realm;
this.allVideos = () => {
console.log(`this.allVideos: ${this}, ${this.realm}`);
const videos = this.realm.objects('Video');
if (videos.length === undefined) {
console.log(`!!!! Find a Realm\'s bug: videos should be array but it is ${videos}`);
return null;
} else {
console.log(`allVideos: ${videos.length} ${videos}`);
}
return videos;
}
My log
!!!! Find a Realm's bug: videos should be array but it is 1
Version of Realm and Tooling
- Realm JS SDK Version: 2.2
- Node or React Native: 0.29
- Client OS & Version: iOS 11
- Which debugger for React Native: Chrome
Issue Analytics
- State:
- Created 6 years ago
- Comments:21 (6 by maintainers)
Top Results From Across the Web
Realm.Object - MongoDB
Returns : Realm.Results the objects that link to this object. Since: 1.9.0. linkingObjectsCount() number. Returns the total count of incoming links to this ......
Read more >Realm.objects() return empty objects on React Native
Realm does define a toJSON() function on Result objects. This can be useful for coercing the object into the actual value. instead of:...
Read more >Class: Collection - Realm
The number of objects in the collection. ... entries() Iterator ... If this function returns true for every object, then this method will...
Read more >Realm Database on Android: Getting Started
Use where(PetRealm::class.java) to retrieve PetRealm objects. findAll() executes the query and returns every PetRealm object. Map PetRealm ...
Read more >[Solved]-How to observe objects count on realm db-swift
Coding example for the question How to observe objects count on realm db-swift. ... Error> { return changeNotificationsRaw().flatMap(.concat) { realmChange ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, just want to share with you how I fixed this issue:
I have replaced all my addListener(this.listener); with the following addListener((results)=>setImmediate(this.listener, results));
Realm guys, I guess this should give you hint where to find the bug Hopefully it will save a day someone )))
Ran into this as well. Can confirm it was occurring while debugging.
Solved by converting the RealmObject into a plain object immediately.
if you’re relying on realm for dynamic models/collections obviously this won’t help