Realm with React Native, how to query through list objects

I noticed this question (Use React Native Realm to Query through multiple List Objects) but was unable to get my query to work with the provided answer from @blackpla9ue.

I have the following schemas/models, and I want to query where ProductReview->productId is equal to 123, and Review->reviewText contains "a simple string".

This query simply returns all reviews for productId 123.

let allReviews = realm.objects('ProductReview', 'productId = "123");
let reviews = allReviews.filtered('reviews.reviewText CONTAINS[c] "a simple string"');

I have also tried removing 'productId = "123"' which simply results in all product reviews being returned for all products. It seems to either be completely ignoring filtered or I am missing something.

class ProductReview extends Realm.Object{}
ProductReview.schema = {
  name: 'ProductReview',
  primaryKey: 'productId',
  properties: {
      productId: 'string',
      averageRating: 'float',
      totalReviewCount: 'int',
      reviews: {type: 'list', objectType: 'Review'},


class Review extends Realm.Object{}
Review.schema = {
   name: 'Review',
   properties: {
     rating: 'float',
     title: {type: 'string', optional: true},
     reviewText: {type: 'string', optional: true},
     userLocation: {type: 'string', optional: true},
     userNickName: {type: 'string', optional: true},
     tags: {type: 'list', objectType: 'StringList'}

Looking to see what I might be doing wrong here.


According to the docs, it seems to me that the query you're possibly looking for is

let allReviews = realm.objects('ProductReview');
let reviews = allReviews.filtered(
                 'productId = "123" AND reviews.reviewText CONTAINS[c] "a simple string"');

the renderscene of the navigator component should be:

{ title, gamekey, passprops } = route;
return react.createelement(route.component, {

you can just delete the app from the device or the simulator to reset the realm.

you can filter through nested objects.

let tasks = realm.objects('dog');
let xyztasks = task.filtered('reservations.renters.first_name beginswith "xyz" or reservations.renters.last_name beginswith "xyz"');


Tags: Database Mobile React Native Realm