Help needed to construct query with nested object


#1

Hi There,

I need help to write correct query to fetch object from list with AND condition:
import Realm from ‘realm’;
export default class ProductModel extends Realm.Object { }
ProductModel.schema = {
name: ‘ProductModel’,
properties: {
productAttributes: { type: ‘list’, objectType: ‘ProductDetailsModel’ },
ID: { type: ‘string’, optional: true },
}
};

mport Realm from ‘realm’;
export default class ProductDetailsModel extends Realm.Object { }
ProductDetailsModel.schema = {
name: ‘ProductDetailsModel’,
properties: {
attributeName: { type: ‘string’, optional: true },
attributeValue: { type: ‘string’, optional: true },
}
};

I have tried and incorrect query is:
let query = “ProductDetailsModel.attributeName = " + “”” + “Manufacturer” + “”" + " AND ProductDetailsModel.attributeValue = [c]" + “”" + “Pepsico” + “”";

    var productList = this.realm.objects('ProductModel').filtered(query).snapshot();

Need query to fetch ProductModel which satisfies below condition:
ProductDetailsModel where attributeName =“Manufacturer” AND attributeValue = “Pepsico”

Complete question and details are her:


#2
let attributeName = "Manufacturer"
let attributeValue = "Pepsico"
let query = `productAttributes.attributeName  ==[c] '${attributeName}' AND productAttributes.attributeValue ==[c] '${attributeValue}'`