How to filter ID from Realm

3iL

I am trying to filter out a id from Realm object like this:

let itemsInCart = realm.objects("Cart").filtered("id = " + itemId);

My Cart schema is as follows:

export const CART_SCHEMA = "Cart";
export const CartSchema = {
  name: CART_SCHEMA,
  primaryKey: "id",
  properties: {
    id: "string",
    quantity: "int",
    productName: "string",
    productImage: "string"
  }
};

I want to check whether the id exists or not in my Cart object but whenever I try to filter out the id it gives the following error:

enter image description here

SinishaS

Try this to filter object by ID in Realm

let itemsInCart = realm.objects("Cart").filtered("id == $0", itemId);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to filter object from Realm database in Swift

How can I filter by specific date from realm object in swift?

How to filter Realm objects by list

How to filter the data in realm adapter?

Filter realm results with variable id using RxSwift

How to filter data from array using the id?

Filter by day from NSDate in Realm, Swift

How to filter Realm objects via an NSDate property

how to dynamically filter with react-native realm

How use I filter in realm when filter data disposed

How to read data from Realm

How to get Realm Objects by ID only?

How to fetch User from Database in Filter and add Id in jwt response?

How to filter out objects from array of object on the basics of object id

How to filter json objects from an array by ID and pass to recyclerview

How to filter a ListView output based on ID from current URL

How can I filter to an array and choose a random Id from it?

How to filter according to id

How to filter by id?

Get associated object value from filter query using Realm swift

On Android, how can I build a Realm Adapter from a Realm List?

How to filter by item contained in a list in realm react native?

How do I filter events created for the current date in the Realm swift?

How can I filter a Realm List by Date Swift NSPredicates

How to migrate data from Sqlite to Realm

How to collect data from multiple schemas ? - Realm

In realm, how to query from a RealmList (Android)

How to delete object from Realm Database Android?

How to get specific changes from ChangeListener in Realm