Docs Menu

Docs HomeRealm

Filter Data - Kotlin SDK

Filter results to retrieve a specific segment of objects with realm.query(). In the argument of realm.query(), use Realm Query Language to perform filtering. Realm Query Language is a string-based query language that you can use to retrieve objects from a realm. Specify the object type as a type parameter passed to query().

For more information on constructing queries, refer to the Realm Query Language reference documentation.

// Find frogs where name is 'Michigan J. Frog'
val michiganFrogs: RealmResults<Frog> =
realm.query<Frog>("name = 'Michigan J. Frog'").find()
// Find frogs where age > 3 AND species is 'Green'
val oldGreenFrogs: RealmResults<Frog> =
realm.query<Frog>("age > 3 AND species = 'green'").find()
←  Find Objects of a Type - Kotlin SDKSort Queries - Kotlin SDK →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.