forked from mongodb/docs-realm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee9ea19
commit 26f31df
Showing
17 changed files
with
320 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
source/examples/generated/kotlin/ReadTest.snippet.find-by-primary-key.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
val queryByPrimaryKey = realm.query<Frog>("_id == $0", PRIMARY_KEY_VALUE).find().first() | ||
val filterByPrimaryKey = realm.query<Frog>("_id == $0", PRIMARY_KEY_VALUE) | ||
val findPrimaryKey = filterByPrimaryKey.find().first() |
6 changes: 0 additions & 6 deletions
6
source/examples/generated/kotlin/ReadTest.snippet.frozen-vs-live-results.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
// 'Realm.query()' always returns frozen results | ||
val frozenResults = realm.query<Frog>("age > $0", 50).find() | ||
// If you try to modify the queried object, SDK throws 'IllegalStateException' | ||
frozenResults.first().age += 1 | ||
|
||
// 'MutableRealm.query()' returns live results | ||
// Open a write transaction to access the MutableRealm | ||
realm.write { // this: MutableRealm | ||
val liveResults = this.query<Frog>("age > $0", 50).find() | ||
// You can modify queried object | ||
liveResults.first().age += 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
source/examples/generated/kotlin/ReadTest.snippet.query-by-property.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
val queryByProperty = realm.query<Frog>("name == $0", "Kermit") | ||
val frogsNamedKermit = queryByProperty.find() | ||
val filterByProperty = realm.query<Frog>("name == $0", "Kermit") | ||
val frogsNamedKermit = filterByProperty.find() |
4 changes: 2 additions & 2 deletions
4
source/examples/generated/kotlin/ReadTest.snippet.query-embedded-object-property.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// Use dot notation to access the embedded object properties as if it | ||
// were in a regular nested object | ||
val queryEmbeddedObjectProperty = | ||
val filterEmbeddedObjectProperty = | ||
realm.query<Contact>("address.street == '123 Pond St'") | ||
|
||
// You can also query properties nested within the embedded object | ||
// You can also access properties nested within the embedded object | ||
val queryNestedProperty = realm.query<Contact>() | ||
.query("address.propertyOwner.name == $0", "Mr. Frog") |
2 changes: 2 additions & 0 deletions
2
source/examples/generated/kotlin/ReadTest.snippet.query-fts-property.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
source/examples/generated/kotlin/ReadTest.snippet.query-inverse-persisted-name.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Query by the remapped name 'Blog_Author' | ||
// Filter by the remapped object type name | ||
// using `@links.<RemappedObjectType>.<PropertyName>` syntax | ||
val postsByKermit = realm.query<Post>() | ||
.query("@links.Blog_Author.posts.name == $0", "Kermit") | ||
.find() |
20 changes: 12 additions & 8 deletions
20
source/examples/generated/kotlin/ReadTest.snippet.query-inverse-relationship.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
source/examples/generated/kotlin/ReadTest.snippet.query-realmany-property.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
val queryFrogLovesNumbers = realm.query<Frog>("favoriteThing.@type == 'int'") | ||
val findFrog = queryFrogLovesNumbers.find().first() | ||
val filterByRealmAnyInt = realm.query<Frog>("favoriteThing.@type == 'int'") | ||
val findFrog = filterByRealmAnyInt.find().first() |
9 changes: 6 additions & 3 deletions
9
source/examples/generated/kotlin/ReadTest.snippet.query-remapped-property.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
val queryKotlinName = realm.query<Frog>("species == $0", "Muppetarium Amphibius").find().first() | ||
val queryRemappedName = realm.query<Frog>("latin_name == $0", "Muppetarium Amphibius").find().first() | ||
val filterByKotlinName = realm.query<Frog>("species == $0", "Muppetarium Amphibius") | ||
val findSpecies = filterByKotlinName.find().first() | ||
|
||
val filterByRemappedName = realm.query<Frog>("latin_name == $0", "Muppetarium Amphibius") | ||
val find_latin_name = filterByRemappedName.find().first() | ||
|
||
// Both queries return the same object | ||
assertEquals(queryKotlinName, queryRemappedName) | ||
assertEquals(findSpecies, find_latin_name) |
2 changes: 1 addition & 1 deletion
2
source/examples/generated/kotlin/ReadTest.snippet.query-to-many-relationship.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
source/examples/generated/kotlin/ReadTest.snippet.read-realm-object.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
source/examples/generated/kotlin/ReadTest.snippet.read-realm-set.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.