From ad32aa9bb92c2ad4b84215c5e158add86af3a9e2 Mon Sep 17 00:00:00 2001 From: Dachary Date: Fri, 16 Aug 2024 15:12:51 -0400 Subject: [PATCH] (DOCSP-39514): Consolidate Read page (#3357) ## Pull Request Info - SDK Docs Consolidation Jira ticket: https://jira.mongodb.org/browse/DOCSP-39514 *Staged Page* - [Read](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39514/sdk/crud/read/) - [Read Properties](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39514/sdk/crud/read/read-properties/) - [Fluent Interface (Java SDK)](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39514/sdk/crud/query-engines/filter-data-java-sdk/): Port content, update Realm naming, and change to use the Drivers tab languages so it preserves a language selection when clicking into the page - [LINQ (.NET SDK)](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39514/sdk/crud/query-engines/filter-data-linq/): Port LINQ content, update Realm naming, omit stuff about querying with RQL as that is generally surfaced in the C# API descriptions on the Read page *Page Source* Add links to every SDK's pages where you got the SDK-specific information: - [C++: Read](https://www.mongodb.com/docs/atlas/device-sdks/sdk/cpp/crud/read/) - [Flutter: Read](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/crud/read/) - [Flutter: Model Data/Results](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/realm-database/model-data/data-types/#realmresults) - [Flutter: Model Data/Geospatial Data](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/realm-database/model-data/geospatial/) - [Java: Read](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/crud/read/) - [Java: Filter Data](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/crud/filter-data/) - [Java: Model Data/Results](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/model-data/data-types/collections/#results-collections) - [Java: Data Types/Mixed (Queries)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/model-data/data-types/realmany/#queries) - [Kotlin: Read](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/realm-database/crud/read/) - [Kotlin: Model Data/Geospatial Data](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/realm-database/schemas/geospatials/) - [.NET: Read](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/crud/read/) - [.NET: Filter Data](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/crud/filter/) - [.NET: Results Collections](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/model-data/data-types/collections/) - [.NET: Geospatial Data](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/model-data/data-types/geospatials/) - [Node.js: Read](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/crud/read/) - [Node.js: Collections (info about Results)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/data-types/collections/) - [Node.js: Relationships (Inverse relationship info](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/relationships-and-embedded-objects/) - [Node.js: Data Types/Dictionaries (Query)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/data-types/dictionaries/#query-for-objects-with-a-dictionary-property) - [Node.js: Data Types/Sets (info relevant to reading set properties)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/data-types/sets/) - [Node.js: Data Types/Mixed (Query)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/data-types/mixed/#query-for-objects-with-a-mixed-value) - [Node.js: Data Types/Geospatial (Query)](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/model-data/data-types/geospatial/#query-geospatial-data) - [Swift: Read](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/crud/read/) - [Swift: Supported Types: Results & Sectioned Results](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/model-data/supported-types/#results-and-sectioned-results) ### PR Author Checklist Before requesting a review for your PR, please check these items: - [x] Open the PR against the `feature-consolidated-sdk-docs` branch instead of `master` - [x] Tag the consolidated page for: - genre - meta.keywords - meta.description #### Naming - [x] Update Realm naming and the language around persistence layer/local/device per [this document](https://docs.google.com/document/d/126OczVxBWAwZ4P5ZsSM29WI3REvONEr1ald-mAwPtyQ/edit?usp=sharing) - [x] Include `.rst` files comply with [the naming guidelines](https://docs.google.com/document/d/1h8cr66zoEVeXytVfvDxlCSsUS5IZwvUQvfSCEXNMpek/edit#heading=h.ulh8b5f2hu9) #### Links and Refs - [x] Create new consolidated SDK ref targets starting with "_sdks-" for relevant sections - [x] Remove or update any SDK-specific refs to use the new consolidated SDK ref targets - [x] [Update any Kotlin API links](https://jira.mongodb.org/browse/DOCSP-32519) to use the new Kotlin SDK roles #### Content - [x] Shared code boxes have snippets or placeholders for all 9 languages - [x] API description sections have API details or a generic placeholder for all 9 languages - [x] Check related pages for relevant content to include - [x] Create a ticket for missing examples in each relevant SDK: Consolidation Gaps epic ### Reviewer Checklist As a reviewer, please check these items: - [ ] Shared code example boxes contain language-specific snippets or placeholders for every language - [ ] API reference details contain working API reference links or generic content - [ ] Realm naming/language has been updated - [ ] All relevant content from individual SDK pages is present on the consolidated page --- snooty.toml | 1 + .../crud/read-access-results-description.rst | 7 + .../cpp/crud/read-aggregate-not-supported.rst | 1 + .../read-all-objects-of-type-description.rst | 6 + .../crud/read-database-objects-procedure.rst | 25 + ...ad-filter-or-query-objects-description.rst | 11 + ...nd-object-by-primary-key-not-supported.rst | 3 + .../cpp/crud/read-intro-description.rst | 7 + .../cpp/crud/read-limit-not-supported.rst | 3 + ...uery-dictionary-properties-description.rst | 3 + ...read-query-list-properties-description.rst | 6 + ...ead-query-mixed-properties-description.rst | 6 + .../read-query-set-properties-description.rst | 3 + ...ad-sdk-results-collections-description.rst | 20 + .../cpp/crud/read-sort-description.rst | 22 + .../crud/read-access-results-description.rst | 5 + .../crud/read-aggregate-description.rst | 9 + .../read-all-objects-of-type-description.rst | 3 + .../crud/read-database-objects-procedure.rst | 25 + ...fine-geospatial-shapes-box-description.rst | 12 + ...e-geospatial-shapes-circle-description.rst | 13 + ...-geospatial-shapes-polygon-description.rst | 12 + ...-full-text-search-property-description.rst | 11 + ...ad-filter-or-query-objects-description.rst | 35 + ...find-object-by-primary-key-description.rst | 3 + .../csharp/crud/read-intro-description.rst | 7 + .../csharp/crud/read-limit-description.rst | 7 + ...uery-dictionary-properties-description.rst | 9 + ...read-query-geospatial-data-description.rst | 10 + ...query-inverse-relationship-description.rst | 3 + ...read-query-list-properties-description.rst | 11 + ...ead-query-mixed-properties-description.rst | 7 + .../read-query-set-properties-description.rst | 11 + ...query-to-many-relationship-description.rst | 9 + ...-query-to-one-relationship-description.rst | 2 + ...ery-with-geospatial-shapes-description.rst | 11 + ...ad-sdk-results-collections-description.rst | 13 + .../csharp/crud/read-sort-description.rst | 2 + .../crud/read-access-results-description.rst | 23 + .../dart/crud/read-aggregate-description.rst | 4 + .../read-all-objects-of-type-description.rst | 2 + .../crud/read-database-objects-procedure.rst | 24 + ...fine-geospatial-shapes-box-description.rst | 5 + ...e-geospatial-shapes-circle-description.rst | 18 + ...-geospatial-shapes-polygon-description.rst | 14 + ...-full-text-search-property-description.rst | 5 + ...ad-filter-or-query-objects-description.rst | 8 + ...find-object-by-primary-key-description.rst | 2 + .../dart/crud/read-intro-description.rst | 8 + ...uery-dictionary-properties-description.rst | 6 + ...read-query-geospatial-data-description.rst | 12 + ...query-inverse-relationship-description.rst | 16 + ...read-query-list-properties-description.rst | 11 + ...ead-query-mixed-properties-description.rst | 7 + .../read-query-set-properties-description.rst | 6 + ...ery-with-geospatial-shapes-description.rst | 5 + ...ad-sdk-results-collections-description.rst | 17 + .../dart/crud/read-sort-description.rst | 5 + ...ull-text-search-property-not-supported.rst | 2 + .../read-geospatial-data-not-supported.rst | 3 + ...tom-persistable-property-not-supported.rst | 1 + .../read-query-projections-not-supported.rst | 1 + ...ad-section-query-results-not-supported.rst | 3 + .../crud/read-access-results-description.rst | 21 + .../java/crud/read-aggregate-description.rst | 12 + .../read-all-objects-of-type-description.rst | 3 + .../crud/read-database-objects-procedure.rst | 25 + ...lter-or-query-objects-java-description.rst | 32 + ...er-or-query-objects-kotlin-description.rst | 33 + ...nd-object-by-primary-key-not-supported.rst | 5 + .../java/crud/read-intro-description.rst | 4 + .../java/crud/read-limit-description.rst | 3 + ...uery-dictionary-properties-description.rst | 4 + ...-inverse-relationship-java-description.rst | 13 + ...nverse-relationship-kotlin-description.rst | 13 + ...read-query-list-properties-description.rst | 3 + ...ead-query-mixed-properties-description.rst | 7 + .../read-query-set-properties-description.rst | 17 + ...y-to-one-relationship-java-description.rst | 14 + ...to-one-relationship-kotlin-description.rst | 14 + ...ad-sdk-results-collections-description.rst | 40 + .../java/crud/read-sort-description.rst | 2 + .../read-access-results-js-ts-description.rst | 21 + .../crud/read-aggregate-description.rst | 4 + ...-all-objects-of-type-js-ts-description.rst | 5 + .../read-database-objects-js-ts-procedure.rst | 24 + ...eospatial-shapes-box-js-ts-description.rst | 3 + ...patial-shapes-circle-js-ts-description.rst | 8 + ...atial-shapes-polygon-js-ts-description.rst | 13 + ...-full-text-search-property-description.rst | 2 + ...ter-or-query-objects-js-ts-description.rst | 10 + ...bject-by-primary-key-js-ts-description.rst | 2 + .../crud/read-intro-js-ts-description.rst | 6 + ...ictionary-properties-js-ts-description.rst | 11 + ...uery-geospatial-data-js-ts-description.rst | 15 + ...inverse-relationship-js-ts-description.rst | 10 + ...uery-list-properties-js-ts-description.rst | 3 + ...ery-mixed-properties-js-ts-description.rst | 5 + .../read-query-set-properties-description.rst | 29 + ...th-geospatial-shapes-js-ts-description.rst | 5 + ...-results-collections-js-ts-description.rst | 14 + .../crud/read-sort-js-ts-description.rst | 2 + .../crud/read-access-results-description.rst | 42 + .../crud/read-aggregate-description.rst | 11 + .../read-all-objects-of-type-description.rst | 4 + .../crud/read-database-objects-procedure.rst | 48 + ...fine-geospatial-shapes-box-description.rst | 4 + ...e-geospatial-shapes-circle-description.rst | 18 + ...-geospatial-shapes-polygon-description.rst | 13 + ...-by-remapped-property-name-description.rst | 8 + ...-full-text-search-property-description.rst | 3 + ...ad-filter-or-query-objects-description.rst | 8 + ...nd-object-by-primary-key-not-supported.rst | 6 + .../kotlin/crud/read-intro-description.rst | 7 + .../kotlin/crud/read-limit-description.rst | 3 + ...uery-dictionary-properties-description.rst | 7 + ...read-query-geospatial-data-description.rst | 13 + ...query-inverse-relationship-description.rst | 13 + ...read-query-list-properties-description.rst | 6 + ...ead-query-mixed-properties-description.rst | 37 + .../read-query-set-properties-description.rst | 6 + ...query-to-many-relationship-description.rst | 2 + ...-query-to-one-relationship-description.rst | 2 + ...ery-with-geospatial-shapes-description.rst | 5 + ...ad-sdk-results-collections-description.rst | 17 + .../kotlin/crud/read-sort-description.rst | 3 + ...property-to-different-name-description.rst | 2 +- .../crud/read-access-results-description.rst | 21 + .../crud/read-aggregate-description.rst | 7 + .../read-all-objects-of-type-description.rst | 7 + .../crud/read-chain-queries-description.rst | 2 + .../crud/read-database-objects-procedure.rst | 29 + ...fine-geospatial-shapes-box-description.rst | 3 + ...e-geospatial-shapes-circle-description.rst | 16 + ...-geospatial-shapes-polygon-description.rst | 11 + ...ad-filter-or-query-objects-description.rst | 6 + ...find-object-by-primary-key-description.rst | 3 + .../crud/read-intro-description.rst | 8 + .../crud/read-limit-not-supported.rst | 3 + ...ustom-persistable-property-description.rst | 36 + ...uery-dictionary-properties-description.rst | 22 + ...read-query-geospatial-data-description.rst | 11 + ...query-inverse-relationship-description.rst | 7 + ...read-query-list-properties-description.rst | 3 + ...ead-query-mixed-properties-description.rst | 21 + ...-query-projections-missing-description.rst | 2 + .../read-query-set-properties-description.rst | 4 + ...ery-with-geospatial-shapes-description.rst | 4 + ...ad-sdk-results-collections-description.rst | 26 + ...read-section-query-results-description.rst | 14 + .../objectivec/crud/read-sort-description.rst | 4 + .../crud/read-access-results-description.rst | 23 + .../swift/crud/read-aggregate-description.rst | 12 + .../read-all-objects-of-type-description.rst | 22 + .../crud/read-chain-queries-description.rst | 2 + .../crud/read-database-objects-procedure.rst | 26 + ...fine-geospatial-shapes-box-description.rst | 3 + ...e-geospatial-shapes-circle-description.rst | 17 + ...-geospatial-shapes-polygon-description.rst | 11 + ...ad-filter-or-query-objects-description.rst | 29 + ...find-object-by-primary-key-description.rst | 3 + .../swift/crud/read-intro-description.rst | 6 + .../swift/crud/read-limit-not-supported.rst | 3 + ...ustom-persistable-property-description.rst | 39 + ...uery-dictionary-properties-description.rst | 10 + ...read-query-geospatial-data-description.rst | 10 + ...query-inverse-relationship-description.rst | 6 + ...read-query-list-properties-description.rst | 12 + ...ead-query-mixed-properties-description.rst | 21 + .../read-query-projections-description.rst | 8 + .../read-query-set-properties-description.rst | 4 + ...ery-with-geospatial-shapes-description.rst | 12 + ...ad-sdk-results-collections-description.rst | 26 + ...read-section-query-results-description.rst | 29 + .../swift/crud/read-sort-description.rst | 3 + .../crud/read-aggregate-description.rst | 4 + ...-full-text-search-property-description.rst | 8 + .../read-query-set-properties-description.rst | 20 + .../sdk-examples/crud/read-access-results.rst | 70 + .../sdk-examples/crud/read-aggregate.rst | 66 + .../crud/read-all-objects-of-type.rst | 63 + .../sdk-examples/crud/read-chain-queries.rst | 70 + .../read-define-geospatial-shapes-box.rst | 66 + .../read-define-geospatial-shapes-circle.rst | 66 + .../read-define-geospatial-shapes-polygon.rst | 67 + .../read-filter-by-remapped-property-name.rst | 71 + .../read-filter-full-text-search-property.rst | 69 + .../crud/read-filter-or-query-objects.rst | 63 + .../crud/read-find-object-by-primary-key.rst | 64 + .../includes/sdk-examples/crud/read-limit.rst | 69 + .../crud/read-query-dictionary-properties.rst | 67 + .../crud/read-query-inverse-relationship.rst | 66 + .../crud/read-query-list-properties.rst | 70 + .../crud/read-query-mixed-properties.rst | 69 + .../crud/read-query-set-properties.rst | 67 + .../crud/read-query-to-many-relationship.rst | 69 + .../crud/read-query-to-one-relationship.rst | 70 + .../read-query-with-geospatial-shapes-box.rst | 73 ++ ...ad-query-with-geospatial-shapes-circle.rst | 73 ++ ...d-query-with-geospatial-shapes-polygon.rst | 74 ++ .../read-query-with-geospatial-shapes.rst | 66 + .../includes/sdk-examples/crud/read-sort.rst | 65 + .../query/rql-example-data-model.rst | 2 +- source/index.txt | 2 +- .../platforms/apple/use-sdk-with-actors.txt | 4 +- source/sdk/crud.txt | 2 +- source/sdk/crud/query-engines.txt | 4 +- .../query-engines/filter-data-java-sdk.txt | 600 ++++++++- .../crud/query-engines/filter-data-linq.txt | 264 +++- .../query-engines/filter-data-swift-sdk.txt | 10 +- .../query-engines/realm-query-language.txt | 28 +- source/sdk/crud/read.txt | 891 ++++++++++++- source/sdk/crud/read/read-properties.txt | 1166 +++++++++++++++++ source/sdk/model-data/property-types.txt | 5 + source/sdk/quick-start.txt | 2 +- source/sdk/sync/manage-sync-subscriptions.txt | 4 +- 216 files changed, 6508 insertions(+), 55 deletions(-) create mode 100644 source/includes/api-details/cpp/crud/read-access-results-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-aggregate-not-supported.rst create mode 100644 source/includes/api-details/cpp/crud/read-all-objects-of-type-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-database-objects-procedure.rst create mode 100644 source/includes/api-details/cpp/crud/read-filter-or-query-objects-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-find-object-by-primary-key-not-supported.rst create mode 100644 source/includes/api-details/cpp/crud/read-intro-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-limit-not-supported.rst create mode 100644 source/includes/api-details/cpp/crud/read-query-dictionary-properties-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-query-list-properties-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-query-mixed-properties-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-sdk-results-collections-description.rst create mode 100644 source/includes/api-details/cpp/crud/read-sort-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-access-results-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-all-objects-of-type-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-database-objects-procedure.rst create mode 100644 source/includes/api-details/csharp/crud/read-define-geospatial-shapes-box-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-define-geospatial-shapes-circle-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-define-geospatial-shapes-polygon-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-filter-full-text-search-property-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-filter-or-query-objects-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-find-object-by-primary-key-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-intro-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-limit-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-dictionary-properties-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-geospatial-data-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-inverse-relationship-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-list-properties-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-mixed-properties-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-to-many-relationship-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-to-one-relationship-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-query-with-geospatial-shapes-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-sdk-results-collections-description.rst create mode 100644 source/includes/api-details/csharp/crud/read-sort-description.rst create mode 100644 source/includes/api-details/dart/crud/read-access-results-description.rst create mode 100644 source/includes/api-details/dart/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/dart/crud/read-all-objects-of-type-description.rst create mode 100644 source/includes/api-details/dart/crud/read-database-objects-procedure.rst create mode 100644 source/includes/api-details/dart/crud/read-define-geospatial-shapes-box-description.rst create mode 100644 source/includes/api-details/dart/crud/read-define-geospatial-shapes-circle-description.rst create mode 100644 source/includes/api-details/dart/crud/read-define-geospatial-shapes-polygon-description.rst create mode 100644 source/includes/api-details/dart/crud/read-filter-full-text-search-property-description.rst create mode 100644 source/includes/api-details/dart/crud/read-filter-or-query-objects-description.rst create mode 100644 source/includes/api-details/dart/crud/read-find-object-by-primary-key-description.rst create mode 100644 source/includes/api-details/dart/crud/read-intro-description.rst create mode 100644 source/includes/api-details/dart/crud/read-query-dictionary-properties-description.rst create mode 100644 source/includes/api-details/dart/crud/read-query-geospatial-data-description.rst create mode 100644 source/includes/api-details/dart/crud/read-query-inverse-relationship-description.rst create mode 100644 source/includes/api-details/dart/crud/read-query-list-properties-description.rst create mode 100644 source/includes/api-details/dart/crud/read-query-mixed-properties-description.rst create mode 100644 source/includes/api-details/dart/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/dart/crud/read-query-with-geospatial-shapes-description.rst create mode 100644 source/includes/api-details/dart/crud/read-sdk-results-collections-description.rst create mode 100644 source/includes/api-details/dart/crud/read-sort-description.rst create mode 100644 source/includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst create mode 100644 source/includes/api-details/generic/crud/read-geospatial-data-not-supported.rst create mode 100644 source/includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst create mode 100644 source/includes/api-details/generic/crud/read-query-projections-not-supported.rst create mode 100644 source/includes/api-details/generic/crud/read-section-query-results-not-supported.rst create mode 100644 source/includes/api-details/java/crud/read-access-results-description.rst create mode 100644 source/includes/api-details/java/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/java/crud/read-all-objects-of-type-description.rst create mode 100644 source/includes/api-details/java/crud/read-database-objects-procedure.rst create mode 100644 source/includes/api-details/java/crud/read-filter-or-query-objects-java-description.rst create mode 100644 source/includes/api-details/java/crud/read-filter-or-query-objects-kotlin-description.rst create mode 100644 source/includes/api-details/java/crud/read-find-object-by-primary-key-not-supported.rst create mode 100644 source/includes/api-details/java/crud/read-intro-description.rst create mode 100644 source/includes/api-details/java/crud/read-limit-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-dictionary-properties-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-inverse-relationship-java-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-inverse-relationship-kotlin-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-list-properties-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-mixed-properties-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-to-one-relationship-java-description.rst create mode 100644 source/includes/api-details/java/crud/read-query-to-one-relationship-kotlin-description.rst create mode 100644 source/includes/api-details/java/crud/read-sdk-results-collections-description.rst create mode 100644 source/includes/api-details/java/crud/read-sort-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-access-results-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-all-objects-of-type-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-database-objects-js-ts-procedure.rst create mode 100644 source/includes/api-details/javascript/crud/read-define-geospatial-shapes-box-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-define-geospatial-shapes-circle-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-define-geospatial-shapes-polygon-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-filter-full-text-search-property-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-filter-or-query-objects-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-find-object-by-primary-key-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-intro-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-query-dictionary-properties-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-query-geospatial-data-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-query-inverse-relationship-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-query-list-properties-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-query-mixed-properties-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-query-with-geospatial-shapes-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-sdk-results-collections-js-ts-description.rst create mode 100644 source/includes/api-details/javascript/crud/read-sort-js-ts-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-access-results-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-all-objects-of-type-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-database-objects-procedure.rst create mode 100644 source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-box-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-circle-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-polygon-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-filter-by-remapped-property-name-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-filter-full-text-search-property-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-filter-or-query-objects-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-find-object-by-primary-key-not-supported.rst create mode 100644 source/includes/api-details/kotlin/crud/read-intro-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-limit-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-dictionary-properties-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-geospatial-data-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-inverse-relationship-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-list-properties-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-mixed-properties-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-to-many-relationship-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-to-one-relationship-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-query-with-geospatial-shapes-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-sdk-results-collections-description.rst create mode 100644 source/includes/api-details/kotlin/crud/read-sort-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-access-results-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-all-objects-of-type-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-chain-queries-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-database-objects-procedure.rst create mode 100644 source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-box-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-circle-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-polygon-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-filter-or-query-objects-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-find-object-by-primary-key-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-intro-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-limit-not-supported.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-custom-persistable-property-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-dictionary-properties-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-geospatial-data-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-inverse-relationship-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-list-properties-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-mixed-properties-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-projections-missing-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-query-with-geospatial-shapes-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-sdk-results-collections-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-section-query-results-description.rst create mode 100644 source/includes/api-details/objectivec/crud/read-sort-description.rst create mode 100644 source/includes/api-details/swift/crud/read-access-results-description.rst create mode 100644 source/includes/api-details/swift/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/swift/crud/read-all-objects-of-type-description.rst create mode 100644 source/includes/api-details/swift/crud/read-chain-queries-description.rst create mode 100644 source/includes/api-details/swift/crud/read-database-objects-procedure.rst create mode 100644 source/includes/api-details/swift/crud/read-define-geospatial-shapes-box-description.rst create mode 100644 source/includes/api-details/swift/crud/read-define-geospatial-shapes-circle-description.rst create mode 100644 source/includes/api-details/swift/crud/read-define-geospatial-shapes-polygon-description.rst create mode 100644 source/includes/api-details/swift/crud/read-filter-or-query-objects-description.rst create mode 100644 source/includes/api-details/swift/crud/read-find-object-by-primary-key-description.rst create mode 100644 source/includes/api-details/swift/crud/read-intro-description.rst create mode 100644 source/includes/api-details/swift/crud/read-limit-not-supported.rst create mode 100644 source/includes/api-details/swift/crud/read-query-custom-persistable-property-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-dictionary-properties-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-geospatial-data-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-inverse-relationship-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-list-properties-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-mixed-properties-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-projections-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-set-properties-description.rst create mode 100644 source/includes/api-details/swift/crud/read-query-with-geospatial-shapes-description.rst create mode 100644 source/includes/api-details/swift/crud/read-sdk-results-collections-description.rst create mode 100644 source/includes/api-details/swift/crud/read-section-query-results-description.rst create mode 100644 source/includes/api-details/swift/crud/read-sort-description.rst create mode 100644 source/includes/api-details/typescript/crud/read-aggregate-description.rst create mode 100644 source/includes/api-details/typescript/crud/read-filter-full-text-search-property-description.rst create mode 100644 source/includes/api-details/typescript/crud/read-query-set-properties-description.rst create mode 100644 source/includes/sdk-examples/crud/read-access-results.rst create mode 100644 source/includes/sdk-examples/crud/read-aggregate.rst create mode 100644 source/includes/sdk-examples/crud/read-all-objects-of-type.rst create mode 100644 source/includes/sdk-examples/crud/read-chain-queries.rst create mode 100644 source/includes/sdk-examples/crud/read-define-geospatial-shapes-box.rst create mode 100644 source/includes/sdk-examples/crud/read-define-geospatial-shapes-circle.rst create mode 100644 source/includes/sdk-examples/crud/read-define-geospatial-shapes-polygon.rst create mode 100644 source/includes/sdk-examples/crud/read-filter-by-remapped-property-name.rst create mode 100644 source/includes/sdk-examples/crud/read-filter-full-text-search-property.rst create mode 100644 source/includes/sdk-examples/crud/read-filter-or-query-objects.rst create mode 100644 source/includes/sdk-examples/crud/read-find-object-by-primary-key.rst create mode 100644 source/includes/sdk-examples/crud/read-limit.rst create mode 100644 source/includes/sdk-examples/crud/read-query-dictionary-properties.rst create mode 100644 source/includes/sdk-examples/crud/read-query-inverse-relationship.rst create mode 100644 source/includes/sdk-examples/crud/read-query-list-properties.rst create mode 100644 source/includes/sdk-examples/crud/read-query-mixed-properties.rst create mode 100644 source/includes/sdk-examples/crud/read-query-set-properties.rst create mode 100644 source/includes/sdk-examples/crud/read-query-to-many-relationship.rst create mode 100644 source/includes/sdk-examples/crud/read-query-to-one-relationship.rst create mode 100644 source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-box.rst create mode 100644 source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-circle.rst create mode 100644 source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-polygon.rst create mode 100644 source/includes/sdk-examples/crud/read-query-with-geospatial-shapes.rst create mode 100644 source/includes/sdk-examples/crud/read-sort.rst create mode 100644 source/sdk/crud/read/read-properties.txt diff --git a/snooty.toml b/snooty.toml index f03ff33085..426594606a 100644 --- a/snooty.toml +++ b/snooty.toml @@ -11,6 +11,7 @@ intersphinx = [ toc_landing_pages = [ # New IA "/sdk/crud/create", + "/sdk/crud/read", "/sdk/platforms/android", "/sdk/platforms/apple", "/sdk/platforms/unity", diff --git a/source/includes/api-details/cpp/crud/read-access-results-description.rst b/source/includes/api-details/cpp/crud/read-access-results-description.rst new file mode 100644 index 0000000000..f1837b9357 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-access-results-description.rst @@ -0,0 +1,7 @@ +In C++, the :cpp-sdk:`Results ` type exposes member +functions to work with results. You may want to check the ``.size()`` of a +results set, or access the object at a specific index. + +Additionally, you can iterate through the results, or observe a results +set for changes. For more details about observing the results for changes, +refer to :ref:`sdks-react-to-changes`. diff --git a/source/includes/api-details/cpp/crud/read-aggregate-not-supported.rst b/source/includes/api-details/cpp/crud/read-aggregate-not-supported.rst new file mode 100644 index 0000000000..970a6bb4e9 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-aggregate-not-supported.rst @@ -0,0 +1 @@ +C++ does not currently support aggregate operators. diff --git a/source/includes/api-details/cpp/crud/read-all-objects-of-type-description.rst b/source/includes/api-details/cpp/crud/read-all-objects-of-type-description.rst new file mode 100644 index 0000000000..fbaafd7447 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-all-objects-of-type-description.rst @@ -0,0 +1,6 @@ +To query for objects of a given type in the database, pass the object type +``YourClassName`` to the :cpp-sdk:`db::objects\ ` +member function. + +This returns a :cpp-sdk:`Results ` object +representing all objects of the given type in the database. diff --git a/source/includes/api-details/cpp/crud/read-database-objects-procedure.rst b/source/includes/api-details/cpp/crud/read-database-objects-procedure.rst new file mode 100644 index 0000000000..52bb42f0ac --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-database-objects-procedure.rst @@ -0,0 +1,25 @@ +To find objects stored within a database: + +1. Query for objects of a given type in the database, pass the object type + ``YourClassName`` to the :cpp-sdk:`db::objects ` + member function. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Work with the results. Objects may be frozen or live, depending on whether + you queried a frozen or live database, collection, or object. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection reference the matched objects, which +map directly to data in the database file. This also means that you can +traverse your graph of an object's :ref:`relationships ` +directly through the results of a query. diff --git a/source/includes/api-details/cpp/crud/read-filter-or-query-objects-description.rst b/source/includes/api-details/cpp/crud/read-filter-or-query-objects-description.rst new file mode 100644 index 0000000000..2d98d1bcd9 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-filter-or-query-objects-description.rst @@ -0,0 +1,11 @@ +To filter data, call the ``.where()`` function on a collection with a valid +query. Currently, C++ supports only a subset of RQL operators. + +Supported Query Operators +````````````````````````` + +C++ supports the following query operators: + +- Equality (``==``, ``!=``) +- Greater than/less than (``>``, ``>=``, ``<``, ``<=``) +- Compound queries (``||``, ``&&``) diff --git a/source/includes/api-details/cpp/crud/read-find-object-by-primary-key-not-supported.rst b/source/includes/api-details/cpp/crud/read-find-object-by-primary-key-not-supported.rst new file mode 100644 index 0000000000..902f9c057a --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-find-object-by-primary-key-not-supported.rst @@ -0,0 +1,3 @@ +C++ does not provide a dedicated API to find an object by its primary +key. Instead, you can perform a regular query for objects where the primary +key property matches the desired primary key value. diff --git a/source/includes/api-details/cpp/crud/read-intro-description.rst b/source/includes/api-details/cpp/crud/read-intro-description.rst new file mode 100644 index 0000000000..7312732687 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-intro-description.rst @@ -0,0 +1,7 @@ +Query operationsn return a :cpp-sdk:`results collection +`. Results collections may be either live or +frozen. + +- **Live results** always contain the latest results of the associated query. +- **Frozen results** represent a snapshot that cannot be modified and doesn't + reflect the latest changes to the database. diff --git a/source/includes/api-details/cpp/crud/read-limit-not-supported.rst b/source/includes/api-details/cpp/crud/read-limit-not-supported.rst new file mode 100644 index 0000000000..429456ad0c --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-limit-not-supported.rst @@ -0,0 +1,3 @@ +C++ does not provide an API to limit query results. Instead, rely on the +SDK's lazy loading characteristics to implicitly limit the objects in +memory by only accessing the objects you need for an operation. diff --git a/source/includes/api-details/cpp/crud/read-query-dictionary-properties-description.rst b/source/includes/api-details/cpp/crud/read-query-dictionary-properties-description.rst new file mode 100644 index 0000000000..9880fda43d --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-query-dictionary-properties-description.rst @@ -0,0 +1,3 @@ +You can iterate and check the values of a realm :cpp-sdk:`map property +` +as you would a standard C++ `map `__. diff --git a/source/includes/api-details/cpp/crud/read-query-list-properties-description.rst b/source/includes/api-details/cpp/crud/read-query-list-properties-description.rst new file mode 100644 index 0000000000..a48078c616 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-query-list-properties-description.rst @@ -0,0 +1,6 @@ +You can read, query, and sort a :cpp-sdk:`list +` similar +to working with a :cpp-sdk:`results +` collection. You can also +work with a list as a results set by calling the ``as_results()`` public member +function of the managed list class. diff --git a/source/includes/api-details/cpp/crud/read-query-mixed-properties-description.rst b/source/includes/api-details/cpp/crud/read-query-mixed-properties-description.rst new file mode 100644 index 0000000000..f2de21a9e2 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-query-mixed-properties-description.rst @@ -0,0 +1,6 @@ +The C++ ``mixed`` data type is a union-like object that can represent a value +any of the supported types. It is implemented using the class template +`std::variant `__. +This implementation means that a ``mixed`` property holds a value of +one of its alternative types, or in the case of error - no value. +Your app must handle the type when reading mixed properties. diff --git a/source/includes/api-details/cpp/crud/read-query-set-properties-description.rst b/source/includes/api-details/cpp/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..ffff168ba6 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-query-set-properties-description.rst @@ -0,0 +1,3 @@ +You can iterate, check the size of a set, and find values in a +:cpp-sdk:`set property +`. diff --git a/source/includes/api-details/cpp/crud/read-sdk-results-collections-description.rst b/source/includes/api-details/cpp/crud/read-sdk-results-collections-description.rst new file mode 100644 index 0000000000..6354a0c251 --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-sdk-results-collections-description.rst @@ -0,0 +1,20 @@ +The SDK's :cpp-sdk:`realm::results\ ` +collection is a struct representing objects retrieved from queries. A results +collection represents the lazily-evaluated results of a query operation, and +has these characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from live objects, the results automatically update when the database + contents change. If they derive from frozen objects, they represent only a + snapshot and do not automatically update. +- You cannot manually initialize an empty results set. Results can only + be initialized: + + - As the result of a query. + - From a managed :ref:`list `, using the + :cpp-sdk:`as_results() + ` + member funcion. diff --git a/source/includes/api-details/cpp/crud/read-sort-description.rst b/source/includes/api-details/cpp/crud/read-sort-description.rst new file mode 100644 index 0000000000..d21d66747a --- /dev/null +++ b/source/includes/api-details/cpp/crud/read-sort-description.rst @@ -0,0 +1,22 @@ +Unlike using `std::sort `__, +the SDK's sort implementation preserves the lazy loading of objects. It does +not pull the entire set of results or list objects into memory, but only +loads them into memory when you access them. + +To sort, call the ``.sort()`` function on a list or results set with one or more +:cpp-sdk:`sort_descriptors `. + +A ``sort_descriptor`` includes: + +- The desired key path to sort by, as a string. +- A bool to specify sort order, where``true`` is ascending and ``false`` + is descending. + +In this example, we sort a results set on ``priority`` in descending order. + +.. literalinclude:: /examples/generated/cpp/filter-data.snippet.sort-results-by-single-property.cpp + :language: cpp + +You can also sort a list or results set by multiple sort descriptors. In +this example, we sort a list property on ``assignee`` in ascending order, +and then on ``priority`` in descending order. diff --git a/source/includes/api-details/csharp/crud/read-access-results-description.rst b/source/includes/api-details/csharp/crud/read-access-results-description.rst new file mode 100644 index 0000000000..0e80a5cab7 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-access-results-description.rst @@ -0,0 +1,5 @@ +In C#, the ``Realm.All()`` method returns an ``IQueryable`` instance. +You can apply additional operators to work with the results. + +For a complete list of the available operators, refer to +:dotnet-sdk:`LINQ support ` in the API reference. diff --git a/source/includes/api-details/csharp/crud/read-aggregate-description.rst b/source/includes/api-details/csharp/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..f96ecd8398 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-aggregate-description.rst @@ -0,0 +1,9 @@ +In C#, aggregations use the +:dotnet-sdk:`Filter() ` +method, which can be used to create more complex queries that are currently +unsupported by the LINQ provider. + +For more information on the available aggregate operators, refer to the +:ref:`Realm Query Language aggregate operator reference `. + +The following examples show different ways to aggregate data. diff --git a/source/includes/api-details/csharp/crud/read-all-objects-of-type-description.rst b/source/includes/api-details/csharp/crud/read-all-objects-of-type-description.rst new file mode 100644 index 0000000000..f8151f3595 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-all-objects-of-type-description.rst @@ -0,0 +1,3 @@ +To read all objects of a certain type, call +:dotnet-sdk:`Realm.All\ `, +where ``T`` is the SDK object type. diff --git a/source/includes/api-details/csharp/crud/read-database-objects-procedure.rst b/source/includes/api-details/csharp/crud/read-database-objects-procedure.rst new file mode 100644 index 0000000000..fcc3851514 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-database-objects-procedure.rst @@ -0,0 +1,25 @@ +To find objects stored within a database: + +1. Query for objects of a given type in the database. Pass the object type + to the :dotnet-sdk:`Realm.All\ ` + method. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Work with the results. Objects may be frozen or live, depending on whether + you queried a frozen or live database, collection, or object. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection reference the matched objects, which +map directly to data in the database file. This also means that you can +traverse your graph of an object's :ref:`relationships ` +directly through the results of a query. diff --git a/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-box-description.rst b/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-box-description.rst new file mode 100644 index 0000000000..6e52ecf9f3 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-box-description.rst @@ -0,0 +1,12 @@ +A :dotnet-sdk:`GeoBox ` is a +rectangular shape whose bounds are determined by :dotnet-sdk:`GeoPoint +` coordinates for a bottom-left +and a top-right corner. + +In C#, you can optionally construct a ``GeoBox`` from a set of four doubles, +which represent: + +- ``left``: The longitude of the left edge of the rectangle. +- ``top``: The latitude of the top edge of the rectangle. +- ``right``: The longitude of the right edge of the rectangle. +- ``bottom``: The latitude of the bottom edge of the rectangle. diff --git a/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-circle-description.rst b/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-circle-description.rst new file mode 100644 index 0000000000..7808ed3717 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-circle-description.rst @@ -0,0 +1,13 @@ +A :dotnet-sdk:`GeoCircle ` is a +circular shape whose bounds originate from a central :dotnet-sdk:`GeoPoint +`, and has a size corresponding to +a radius measured in radians. You can use the SDK's convenience +:dotnet-sdk:`Distance ` structure to +easily work with radii in different units. + +You can construct a ``Distance`` with a radius measurement in one of four units: + +- ``FromDegrees(double)`` +- ``FromKilometers(double)`` +- ``FromMiles(double)`` +- ``FromRadians(double)`` diff --git a/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-polygon-description.rst b/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-polygon-description.rst new file mode 100644 index 0000000000..e62dc871d5 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-define-geospatial-shapes-polygon-description.rst @@ -0,0 +1,12 @@ +A :dotnet-sdk:`GeoPolygon ` is a polygon +shape whose bounds consist of an outer ring, and 0 or more inner holes +to exclude from the geospatial query. + +A polygon's outer ring must contain at least three segments. The last +and the first :dotnet-sdk:`GeoPoint ` +must be the same, which indicates a closed polygon. This means that it takes +at least four ``GeoPoint`` values to construct a polygon. + +Inner holes in a ``GeoPolygon`` are optional, and must be entirely contained +within the outer ring. Each ``GeoPoint`` collection in the ``Holes`` collection +must contain at least three segments, with the same rules as the outer ring. diff --git a/source/includes/api-details/csharp/crud/read-filter-full-text-search-property-description.rst b/source/includes/api-details/csharp/crud/read-filter-full-text-search-property-description.rst new file mode 100644 index 0000000000..71ad24fd87 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-filter-full-text-search-property-description.rst @@ -0,0 +1,11 @@ +In C#, you can query a FTS property using either LINQ or RQL. + +To query with LINQ, use :dotnet-sdk:`QueryMethods.FullTextSearch +`. +The following examples query the ``Person.Biography`` field. + +.. literalinclude:: /examples/generated/dotnet/Indexing.snippet.linq-query-fts.cs + :language: csharp + +To query with RQL, use the ``TEXT`` operator. The following example +queries the ``Person.Biography`` field. diff --git a/source/includes/api-details/csharp/crud/read-filter-or-query-objects-description.rst b/source/includes/api-details/csharp/crud/read-filter-or-query-objects-description.rst new file mode 100644 index 0000000000..369d1bdda6 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-filter-or-query-objects-description.rst @@ -0,0 +1,35 @@ +To query, filter, and sort data in the database, use the SDK query engine. +There are two ways to use the query engine with C#: + +- :ref:`LINQ Syntax ` +- :ref:`Realm Query Language (RQL) ` + +Use LINQ syntax for querying when possible, as it provides compile-time checks +for queries and aligns with .NET conventions. + +Filter Data with LINQ +````````````````````` + +To filter data with LINQ syntax, call the :dotnet-sdk:`Where() +` operator with a +:dotnet-sdk:`Predicate ` that describes +the subset of data you want to access. + +.. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.logical.cs + :language: csharp + +Filter Data with RQL +```````````````````` + +You can also use the :ref:`Realm Query Language ` (RQL) +to query realms. RQL is a string-based query language used to access the query +engine. When using RQL, you use the +:dotnet-sdk:`Filter() ` +method. + +.. important:: + + Because :ref:`LINQ ` provides compile-time error checking + of queries, you should use it instead of RQL in most cases. If you require + features beyond LINQ's current capabilities, such as using + :ref:`aggregation `, use RQL. diff --git a/source/includes/api-details/csharp/crud/read-find-object-by-primary-key-description.rst b/source/includes/api-details/csharp/crud/read-find-object-by-primary-key-description.rst new file mode 100644 index 0000000000..13dcecc319 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-find-object-by-primary-key-description.rst @@ -0,0 +1,3 @@ +You can find a specific item by its primary key using the +:dotnet-sdk:`Find ` +method. The following example finds a single Project. diff --git a/source/includes/api-details/csharp/crud/read-intro-description.rst b/source/includes/api-details/csharp/crud/read-intro-description.rst new file mode 100644 index 0000000000..14b2ae6044 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-intro-description.rst @@ -0,0 +1,7 @@ +:dotnet-sdk:`Query operations ` +return an ``IQueryable``, which represents a collection of all objects +of the given type in the database. This collection may be either live or frozen. + +- **Live results** always contain the latest results of the associated query. +- **Frozen results** represent a snapshot that cannot be modified and doesn't + reflect the latest changes to the database. diff --git a/source/includes/api-details/csharp/crud/read-limit-description.rst b/source/includes/api-details/csharp/crud/read-limit-description.rst new file mode 100644 index 0000000000..a3415d03d7 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-limit-description.rst @@ -0,0 +1,7 @@ +The C# LINQ query engine does not provide an API to limit query results. +Instead, rely on the SDK's lazy loading characteristics to implicitly limit +the objects in memory by only accessing the objects you need for an operation. + +If you're using the Realm Query Language query engine with C#, you can use +the :ref:`RQL LIMIT() operator ` to limit query +results. diff --git a/source/includes/api-details/csharp/crud/read-query-dictionary-properties-description.rst b/source/includes/api-details/csharp/crud/read-query-dictionary-properties-description.rst new file mode 100644 index 0000000000..ef6bc3aa7e --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-dictionary-properties-description.rst @@ -0,0 +1,9 @@ +You can query and iterate through a :ref:`RealmDictionary ` +property as you would an +`IDictionary `__. + +The SDK also provides a convenience method to cast an ``IDictionary`` to an +``IRealmCollection``. To convert a dictionary to an SDK collection, call the +:dotnet-sdk:`AsRealmCollection\ +` +method with the ``IDictionary`` as its argument. diff --git a/source/includes/api-details/csharp/crud/read-query-geospatial-data-description.rst b/source/includes/api-details/csharp/crud/read-query-geospatial-data-description.rst new file mode 100644 index 0000000000..ec64994b23 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-geospatial-data-description.rst @@ -0,0 +1,10 @@ +The SDK provides two specialized non-persistable data types to define shapes: + +- :dotnet-sdk:`GeoPoint `: A + struct that represents the coordinates of a point formed by a pair of + doubles consisting of these values: + + - Latitude: ranges between -90 and 90 degrees, inclusive. + - Longitude: ranges between -180 and 180 degrees, inclusive. +- :dotnet-sdk:`Distance `: A helper + struct to represent and convert a distance. diff --git a/source/includes/api-details/csharp/crud/read-query-inverse-relationship-description.rst b/source/includes/api-details/csharp/crud/read-query-inverse-relationship-description.rst new file mode 100644 index 0000000000..6578914172 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-inverse-relationship-description.rst @@ -0,0 +1,3 @@ +To query an inverse relationship in C#, you cannot use LINQ. Instead, pass a +string predicate using RQL. The following example shows how you could find +all Users who have Items that contain the word "oscillator". diff --git a/source/includes/api-details/csharp/crud/read-query-list-properties-description.rst b/source/includes/api-details/csharp/crud/read-query-list-properties-description.rst new file mode 100644 index 0000000000..7e62d6a58f --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-list-properties-description.rst @@ -0,0 +1,11 @@ +SDK lists implement the :dotnet-sdk:`IRealmCollection\ +` interface, which provides a range +of properties and methods to simplify reading and querying from the list. +You can query an SDK list using the same :ref:`query engines and operators +` as a results set. + +The SDK also provides a convenience method to cast an ``IList`` to an +``IRealmCollection``. To convert a list to an SDK collection, call the +:dotnet-sdk:`AsRealmCollection\ +` +method with the ``IList`` as its argument. diff --git a/source/includes/api-details/csharp/crud/read-query-mixed-properties-description.rst b/source/includes/api-details/csharp/crud/read-query-mixed-properties-description.rst new file mode 100644 index 0000000000..efbb1ee105 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-mixed-properties-description.rst @@ -0,0 +1,7 @@ +You can query a :dotnet-sdk:`RealmValue ` +field just like any other data type. Operators that only work with certain +types, such as string operators and arithmetic operators, ignore +values that do not contain that type. Negating such operators matches +values that do not contain the type. Type queries match the underlying +type, rather than ``RealmValue``. Arithmetic operators convert numeric +values implicitly to compare across types. diff --git a/source/includes/api-details/csharp/crud/read-query-set-properties-description.rst b/source/includes/api-details/csharp/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..fd74fb0312 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-set-properties-description.rst @@ -0,0 +1,11 @@ +SDK sets implement the :dotnet-sdk:`IRealmCollection\ +` interface, which provides a range +of properties and methods to simplify reading and querying from the set. +You can query an SDK set using the same :ref:`query engines and operators +` as a results set. + +The SDK also provides a convenience method to cast an ``ISet`` to an +``IRealmCollection``. To convert a set to an SDK collection, call the +:dotnet-sdk:`AsRealmCollection\ +` +method with the ``ISet`` as its argument. diff --git a/source/includes/api-details/csharp/crud/read-query-to-many-relationship-description.rst b/source/includes/api-details/csharp/crud/read-query-to-many-relationship-description.rst new file mode 100644 index 0000000000..82facd1137 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-to-many-relationship-description.rst @@ -0,0 +1,9 @@ +An application could use the following object schemas to indicate +that a Person may own multiple Dogs by including them in its ``dog`` +property: + +.. literalinclude:: /examples/generated/dotnet/Relationships.snippet.one-to-many.cs + :language: csharp + +To see the to-many relationship of Person to Dog, you query for the +Person and get that person's Dogs. diff --git a/source/includes/api-details/csharp/crud/read-query-to-one-relationship-description.rst b/source/includes/api-details/csharp/crud/read-query-to-one-relationship-description.rst new file mode 100644 index 0000000000..47b9c81c12 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-to-one-relationship-description.rst @@ -0,0 +1,2 @@ +To query a direct relationship, you can use LINQ syntax. +See the following example for how to query a one-to-one relationship. diff --git a/source/includes/api-details/csharp/crud/read-query-with-geospatial-shapes-description.rst b/source/includes/api-details/csharp/crud/read-query-with-geospatial-shapes-description.rst new file mode 100644 index 0000000000..772454a25b --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-query-with-geospatial-shapes-description.rst @@ -0,0 +1,11 @@ +You can query geospatial data in two ways: + +- Using the :dotnet-sdk:`GeoWithin() + ` + operator with the :ref:`LINQ ` query engine. +- Using the :dotnet-sdk:`Filter() + ` method with the + :ref:`Realm Query Language ` ``geoWithin`` operator. + +The examples below show the results of queries using these two ``Company`` +objects. diff --git a/source/includes/api-details/csharp/crud/read-sdk-results-collections-description.rst b/source/includes/api-details/csharp/crud/read-sdk-results-collections-description.rst new file mode 100644 index 0000000000..95fc1d5c21 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-sdk-results-collections-description.rst @@ -0,0 +1,13 @@ +The SDK's results collection is a class representing objects retrieved from +queries. A results collection represents the lazily-evaluated results of a +query operation, and has these characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from live objects, the results automatically update when the database + contents change in the isolate context. If they derive from frozen objects, + they represent only a snapshot and do not automatically update. +- You cannot manually initialize an empty results set. Results can + only be initialized as the result of a query. diff --git a/source/includes/api-details/csharp/crud/read-sort-description.rst b/source/includes/api-details/csharp/crud/read-sort-description.rst new file mode 100644 index 0000000000..392eb02406 --- /dev/null +++ b/source/includes/api-details/csharp/crud/read-sort-description.rst @@ -0,0 +1,2 @@ +The following code sorts the projects by name in reverse +alphabetical order (i.e. "descending" order). diff --git a/source/includes/api-details/dart/crud/read-access-results-description.rst b/source/includes/api-details/dart/crud/read-access-results-description.rst new file mode 100644 index 0000000000..c59b992b9f --- /dev/null +++ b/source/includes/api-details/dart/crud/read-access-results-description.rst @@ -0,0 +1,23 @@ +In Dart, the ``RealmResults`` type provides convenience properties and +functions to simplify working with query results. You may want to: + +- Check whether the results set :flutter-sdk:`.isEmpty + `. +- Check the :flutter-sdk:`.length ` of the + results. +- Get the :flutter-sdk:`.first ` or + :flutter-sdk:`.last ` element in the results. +- Check whether the results set :flutter-sdk:`.contains() + ` an individual element. +- Find the :flutter-sdk:`indexOf() ` an + element. +- Get the :flutter-sdk:`elementAt() ` + an index. + +For the full range of available properties and functions to work with the +results set, refer to the the :flutter-sdk:`RealmResults +` API reference. + +Additionally, you can iterate through the results, or observe a results +set for changes. For more details about observing the results for changes, +refer to :ref:`sdks-react-to-changes`. diff --git a/source/includes/api-details/dart/crud/read-aggregate-description.rst b/source/includes/api-details/dart/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..56aa0f676a --- /dev/null +++ b/source/includes/api-details/dart/crud/read-aggregate-description.rst @@ -0,0 +1,4 @@ +In Dart, you perform aggregations through the :flutter-sdk:`Realm.query() +` method. In the ``query()`` method's argument, use +:ref:`Realm Query Language aggregate operators ` to +aggregate data. diff --git a/source/includes/api-details/dart/crud/read-all-objects-of-type-description.rst b/source/includes/api-details/dart/crud/read-all-objects-of-type-description.rst new file mode 100644 index 0000000000..760dc8e1b9 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-all-objects-of-type-description.rst @@ -0,0 +1,2 @@ +Retrieve a collection of all objects of a given type in the database with the +:flutter-sdk:`Realm.all\() ` method. diff --git a/source/includes/api-details/dart/crud/read-database-objects-procedure.rst b/source/includes/api-details/dart/crud/read-database-objects-procedure.rst new file mode 100644 index 0000000000..b3cbe4395e --- /dev/null +++ b/source/includes/api-details/dart/crud/read-database-objects-procedure.rst @@ -0,0 +1,24 @@ +To find objects stored within a database: + +1. Query for objects of a given type in the database. Pass the object type + to the :flutter-sdk:`Realm.all\ ` method. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Work with the results. Objects may be frozen or live, depending on whether + you queried a frozen or live database, collection, or object. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection reference the matched objects, which +map directly to data in the database file. This also means that you can +traverse your graph of an object's :ref:`relationships ` +directly through the results of a query. diff --git a/source/includes/api-details/dart/crud/read-define-geospatial-shapes-box-description.rst b/source/includes/api-details/dart/crud/read-define-geospatial-shapes-box-description.rst new file mode 100644 index 0000000000..4000204d23 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-define-geospatial-shapes-box-description.rst @@ -0,0 +1,5 @@ +A :flutter-sdk:`GeoBox ` is a +rectangular shape whose bounds are determined by :flutter-sdk:`GeoPoint +` coordinates for a bottom-left +and a top-right corner. The SDK refers to these as ``southWest`` and +``northEast``, respectively. diff --git a/source/includes/api-details/dart/crud/read-define-geospatial-shapes-circle-description.rst b/source/includes/api-details/dart/crud/read-define-geospatial-shapes-circle-description.rst new file mode 100644 index 0000000000..e9fe29f2b6 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-define-geospatial-shapes-circle-description.rst @@ -0,0 +1,18 @@ +A :flutter-sdk:`GeoCircle ` is a +circular shape whose bounds originate from a central :flutter-sdk:`GeoPoint +`, and has a size corresponding to +a radius measured in radians. You can use the SDK's convenience +:flutter-sdk:`GeoDistance ` class to +easily work with radii in different units. + +The default constructor for ``GeoDistance()`` takes a double that represents +a distance in radians. You can use the following convenience methods to create +a ``GeoDistance`` from a different measure: + +- ``GeoDistance.fromDegrees(double degrees)`` +- ``GeoDistance.fromKilometers(double kilometers)`` +- ``GeoDistance.fromMeters(double meters)`` +- ``GeoDistance.fromMiles(double miles)`` + +You can optionally access the distance value in any of these units, represented +as a double. diff --git a/source/includes/api-details/dart/crud/read-define-geospatial-shapes-polygon-description.rst b/source/includes/api-details/dart/crud/read-define-geospatial-shapes-polygon-description.rst new file mode 100644 index 0000000000..4d1582c2da --- /dev/null +++ b/source/includes/api-details/dart/crud/read-define-geospatial-shapes-polygon-description.rst @@ -0,0 +1,14 @@ +A :flutter-sdk:`GeoPolygon ` is a polygon +shape whose bounds consist of an outer ring of type :flutter-sdk:`GeoRing +`, and 0 or more inner holes to exclude from the +geospatial query. + +The ``GeoRing`` is a list of three or more :flutter-sdk:`GeoPoint +` coordinates. The last +and the first ``GeoPoint`` must be the same, which indicates a closed ring. +This means that it takes at least four ``GeoPoint`` values to construct a +polygon. + +Inner holes in a ``GeoPolygon`` are optional, and must be entirely contained +within the outer ring. Each ``GeoRing`` collection in the ``holes`` collection +must contain at least three segments, with the same rules as the outer ring. diff --git a/source/includes/api-details/dart/crud/read-filter-full-text-search-property-description.rst b/source/includes/api-details/dart/crud/read-filter-full-text-search-property-description.rst new file mode 100644 index 0000000000..35e9c0cc37 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-filter-full-text-search-property-description.rst @@ -0,0 +1,5 @@ +For more information on features of the FTS index, see the API reference for +`RealmIndexType `__. + +In the following example, we query on the ``Rug.pattern`` and ``Rug.material`` +fields. diff --git a/source/includes/api-details/dart/crud/read-filter-or-query-objects-description.rst b/source/includes/api-details/dart/crud/read-filter-or-query-objects-description.rst new file mode 100644 index 0000000000..49206471ae --- /dev/null +++ b/source/includes/api-details/dart/crud/read-filter-or-query-objects-description.rst @@ -0,0 +1,8 @@ +Filter a collection to retrieve a specific segment of objects with the +:flutter-sdk:`Realm.query() ` method. In the +``query()`` method's argument, use RQL to perform filtering. + +.. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.filter.dart + :language: dart + +You can use iterable arguments in your filter. diff --git a/source/includes/api-details/dart/crud/read-find-object-by-primary-key-description.rst b/source/includes/api-details/dart/crud/read-find-object-by-primary-key-description.rst new file mode 100644 index 0000000000..92f3a21916 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-find-object-by-primary-key-description.rst @@ -0,0 +1,2 @@ +Find an object by its primary key with :flutter-sdk:`Realm.find() +`. diff --git a/source/includes/api-details/dart/crud/read-intro-description.rst b/source/includes/api-details/dart/crud/read-intro-description.rst new file mode 100644 index 0000000000..bfaee79212 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-intro-description.rst @@ -0,0 +1,8 @@ +Query operations return a :flutter-sdk:`results collection +`. + +Results collections may be either live or frozen. + +- **Live results** always contain the latest results of the associated query. +- **Frozen results** represent a snapshot that cannot be modified and doesn't + reflect the latest changes to the database. diff --git a/source/includes/api-details/dart/crud/read-query-dictionary-properties-description.rst b/source/includes/api-details/dart/crud/read-query-dictionary-properties-description.rst new file mode 100644 index 0000000000..2e9d767d90 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-query-dictionary-properties-description.rst @@ -0,0 +1,6 @@ +Get a ``RealmMap`` by property name with +:flutter-sdk:`dynamic.getMap() ` + +The following example demonstrates some basic usage of ``RealmMap``. +For more information about all available methods, refer to the +:flutter-sdk:`RealmMap reference ` documentation. diff --git a/source/includes/api-details/dart/crud/read-query-geospatial-data-description.rst b/source/includes/api-details/dart/crud/read-query-geospatial-data-description.rst new file mode 100644 index 0000000000..0b73129555 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-query-geospatial-data-description.rst @@ -0,0 +1,12 @@ +The SDK provides two specialized non-persistable data types to define shapes: + +- :flutter-sdk:`GeoPoint `: A class that represents + the coordinates of a point formed by a pair of doubles consisting of these + values: + + - ``lat``: a double value representing the latitude of a point. + - ``lon````: a doubble value representing the longitude of a point. +- :flutter-sdk:`GeoDistance `: A double + that represents a distance in radians used to calculate the size of the + circle shape. ``GeoDistance`` provides convenience methods to simplify + converting degrees, kilometers, meters, and miles to radians. diff --git a/source/includes/api-details/dart/crud/read-query-inverse-relationship-description.rst b/source/includes/api-details/dart/crud/read-query-inverse-relationship-description.rst new file mode 100644 index 0000000000..a42eb273b2 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-query-inverse-relationship-description.rst @@ -0,0 +1,16 @@ +In Dart, there are two ways to query inverse relationships. + +You can use the :flutter-sdk:`getBacklinks() +` method to retrieve an object at +the origin of the relationship from the related object. + +Here, we use the ``getBacklinks()`` method to find any ``User`` objects that +link to the specified tasks through the ``tasks`` backlinks property: + +.. literalinclude:: /examples/generated/flutter/backlinks_test.snippet.query-backlink-inverse-relationship.dart + :language: dart + +You can also filter by inverse relationships using the +``@links..`` syntax. For example, a filter can match +a ``Task`` object based on properties of the ``User`` +object that references it. diff --git a/source/includes/api-details/dart/crud/read-query-list-properties-description.rst b/source/includes/api-details/dart/crud/read-query-list-properties-description.rst new file mode 100644 index 0000000000..caf89521a3 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-query-list-properties-description.rst @@ -0,0 +1,11 @@ +Get a ``RealmList`` by property name with +:flutter-sdk:`dynamic.getList() `. + +You can also work with a list as a results set. Call the +:flutter-sdk:`RealmList\.asResults() ` +method to convert the list to a :flutter-sdk:`RealmResults\ +`. + +The following example demonstrates some basic usage of ``RealmList``. +For more information about all available methods, refer to the +:flutter-sdk:`RealmList reference ` documentation. diff --git a/source/includes/api-details/dart/crud/read-query-mixed-properties-description.rst b/source/includes/api-details/dart/crud/read-query-mixed-properties-description.rst new file mode 100644 index 0000000000..6ff1c97fe3 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-query-mixed-properties-description.rst @@ -0,0 +1,7 @@ +You can query a :flutter-sdk:`RealmValue ` +field just like any other data type. Operators that only work with certain +types, such as string operators and arithmetic operators, ignore +values that do not contain that type. Negating such operators matches +values that do not contain the type. Type queries match the underlying +type, rather than ``RealmValue``. Arithmetic operators convert numeric +values implicitly to compare across types. diff --git a/source/includes/api-details/dart/crud/read-query-set-properties-description.rst b/source/includes/api-details/dart/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..6a63b1f2dd --- /dev/null +++ b/source/includes/api-details/dart/crud/read-query-set-properties-description.rst @@ -0,0 +1,6 @@ +Get a ``RealmSet`` by property name with +:flutter-sdk:`dynamic.getSet() `. + +The following example demonstrates some basic usage of ``RealmSet``. +For more information about all available methods, refer to the +:flutter-sdk:`RealmSet reference ` documentation. diff --git a/source/includes/api-details/dart/crud/read-query-with-geospatial-shapes-description.rst b/source/includes/api-details/dart/crud/read-query-with-geospatial-shapes-description.rst new file mode 100644 index 0000000000..6517c73d15 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-query-with-geospatial-shapes-description.rst @@ -0,0 +1,5 @@ +You can query geospatial data using the :ref:`Realm Query Language +` ``geoWithin`` operator. + +The examples below show the results of queries using these two ``Company`` +objects. diff --git a/source/includes/api-details/dart/crud/read-sdk-results-collections-description.rst b/source/includes/api-details/dart/crud/read-sdk-results-collections-description.rst new file mode 100644 index 0000000000..34fb294466 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-sdk-results-collections-description.rst @@ -0,0 +1,17 @@ +The SDK's :flutter-sdk:`RealmResults ` +collection is a class representing objects retrieved from queries. A +``RealmResults`` collection represents the lazily-evaluated results of a query +operation, and has these characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from live objects, the results automatically update when the database + contents change in the isolate context. If they derive from frozen objects, + they represent only a snapshot and do not automatically update. +- You cannot manually initialize an empty ``RealmResults`` set. Results can + only be initialized: + + - As the result of a query. + - From a ``RealmList`` or ``RealmSet``, by calling the ``asResults()`` method. diff --git a/source/includes/api-details/dart/crud/read-sort-description.rst b/source/includes/api-details/dart/crud/read-sort-description.rst new file mode 100644 index 0000000000..e7e1115120 --- /dev/null +++ b/source/includes/api-details/dart/crud/read-sort-description.rst @@ -0,0 +1,5 @@ +Sort query results using the :ref:`Realm Query Language SORT() operator +` in the ``query()`` method's argument. + +Note that you can't use :ref:`parameterized queries ` +in RQL SORT() clauses. Instead, use strings or string interpolation. diff --git a/source/includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst b/source/includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst new file mode 100644 index 0000000000..94fb0846e7 --- /dev/null +++ b/source/includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst @@ -0,0 +1,2 @@ +The selected language does not support Full-Text Search. You cannot currently +model or query a FTS property in this language. diff --git a/source/includes/api-details/generic/crud/read-geospatial-data-not-supported.rst b/source/includes/api-details/generic/crud/read-geospatial-data-not-supported.rst new file mode 100644 index 0000000000..d99533915d --- /dev/null +++ b/source/includes/api-details/generic/crud/read-geospatial-data-not-supported.rst @@ -0,0 +1,3 @@ +The selected language does not currently support persisting and querying +geospatial data. Instead, you can manually define your own logic and types +for working with geospatial data. diff --git a/source/includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst b/source/includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst new file mode 100644 index 0000000000..8ac2a8669e --- /dev/null +++ b/source/includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst @@ -0,0 +1 @@ +The selected language does not currently support type projection. diff --git a/source/includes/api-details/generic/crud/read-query-projections-not-supported.rst b/source/includes/api-details/generic/crud/read-query-projections-not-supported.rst new file mode 100644 index 0000000000..1811385711 --- /dev/null +++ b/source/includes/api-details/generic/crud/read-query-projections-not-supported.rst @@ -0,0 +1 @@ +The selected language does not currently support the class projection APIs. diff --git a/source/includes/api-details/generic/crud/read-section-query-results-not-supported.rst b/source/includes/api-details/generic/crud/read-section-query-results-not-supported.rst new file mode 100644 index 0000000000..b3e1f6b017 --- /dev/null +++ b/source/includes/api-details/generic/crud/read-section-query-results-not-supported.rst @@ -0,0 +1,3 @@ +The selected language does not currently support the sectioned results APIs. +Instead, you can manually define logic to display only a subset of query +results based on the needs of your app. diff --git a/source/includes/api-details/java/crud/read-access-results-description.rst b/source/includes/api-details/java/crud/read-access-results-description.rst new file mode 100644 index 0000000000..568080a3f2 --- /dev/null +++ b/source/includes/api-details/java/crud/read-access-results-description.rst @@ -0,0 +1,21 @@ +In Java and Kotlin (Java SDK), the ``RealmResults`` type provides convenience +functions to work with query results. You may want to: + +- Check the :java-sdk:`.size() ` of a + results set. +- Check whether the results set :java-sdk:`.contains() + ` + an individual element. +- :java-sdk:`get() ` the element at + an index. +- Get the :java-sdk:`.first() ` or + :java-sdk:`.last() ` element in the + results set. + +For the full range of available functions to work with the results set, +refer to the the :java-sdk:`RealmResults ` API +reference. + +Additionally, you can iterate through the results, or observe a results +set for changes. For more details about observing the results for changes, +refer to :ref:`sdks-react-to-changes`. diff --git a/source/includes/api-details/java/crud/read-aggregate-description.rst b/source/includes/api-details/java/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..3a0ba8f582 --- /dev/null +++ b/source/includes/api-details/java/crud/read-aggregate-description.rst @@ -0,0 +1,12 @@ +You can perform aggregation using +:ref:`RQL aggregate operators `, one of the +``RealmQuery`` aggregation methods, or a combination of both. Some of the +common aggregation methods include: + +- :java-sdk:`max() ` +- :java-sdk:`min() ` +- :java-sdk:`sum() ` +- :java-sdk:`count() ` + +For a full list of supported aggregation methods, refer to the +:java-sdk:`RealmQuery ` API reference. diff --git a/source/includes/api-details/java/crud/read-all-objects-of-type-description.rst b/source/includes/api-details/java/crud/read-all-objects-of-type-description.rst new file mode 100644 index 0000000000..47b68eda2a --- /dev/null +++ b/source/includes/api-details/java/crud/read-all-objects-of-type-description.rst @@ -0,0 +1,3 @@ +In order to access all instances of a given type in the database, use +the :java-sdk:`Realm.where() ` +method to specify a class. diff --git a/source/includes/api-details/java/crud/read-database-objects-procedure.rst b/source/includes/api-details/java/crud/read-database-objects-procedure.rst new file mode 100644 index 0000000000..5240a6dcc5 --- /dev/null +++ b/source/includes/api-details/java/crud/read-database-objects-procedure.rst @@ -0,0 +1,25 @@ +To find objects stored within a database: + +1. Query for objects of a given type in the database. Pass the object type + to the :java-sdk:`Realm.where() ` + method. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Work with the results. Objects may be frozen or live, depending on whether + you queried a frozen or live database, collection, or object. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection reference the matched objects, which +map directly to data in the database file. This also means that you can +traverse your graph of an object's :ref:`relationships ` +directly through the results of a query. diff --git a/source/includes/api-details/java/crud/read-filter-or-query-objects-java-description.rst b/source/includes/api-details/java/crud/read-filter-or-query-objects-java-description.rst new file mode 100644 index 0000000000..31c53ef925 --- /dev/null +++ b/source/includes/api-details/java/crud/read-filter-or-query-objects-java-description.rst @@ -0,0 +1,32 @@ +In Java, you can filter objects with either the Fluent interface or RQL. + +Filter Data with Fluent Interface +````````````````````````````````` + +To filter data with the Fluent interface, filter data with a +:java-sdk:`RealmQuery `. For more details, refer +to :ref:`Fluent interface `. + +In the following example, we use the Fluent interface comparison operators to: + +- Find high priority tasks by comparing the value of the ``priority`` property value with a threshold number, above which priority can be considered high. +- Find just-started or short-running tasks by seeing if the ``progressMinutes`` property falls within a certain range. +- Find unassigned tasks by finding tasks where the ``assignee`` property is equal to null. +- Find tasks assigned to specific teammates Ali or Jamie by seeing if the ``assignee`` property is in a list of names. + +.. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.filter-results.java + :language: java + :copyable: false + +Filter Data with RQL +```````````````````` + +To filter data with RQL, use :java-sdk:`RealmQuery.rawPredicate() +`. +For more information about syntax, usage and limitations, +refer to the :ref:`Realm Query Language reference `. + +RQL can use either the class and property names defined in your SDK model +classes or the internal names defined with ``@RealmField``. You can combine +raw predicates with other raw predicates or type-safe predicates created with +``RealmQuery``. diff --git a/source/includes/api-details/java/crud/read-filter-or-query-objects-kotlin-description.rst b/source/includes/api-details/java/crud/read-filter-or-query-objects-kotlin-description.rst new file mode 100644 index 0000000000..f20e572e94 --- /dev/null +++ b/source/includes/api-details/java/crud/read-filter-or-query-objects-kotlin-description.rst @@ -0,0 +1,33 @@ +In Java or Kotlin (Java SDK), you can filter objects with either the +Fluent interface or RQL. + +Filter Data with Fluent Interface +````````````````````````````````` + +To filter data with the Fluent interface, filter data with a +:java-sdk:`RealmQuery `. For more details, refer +to :ref:`Fluent interface `. + +In the following example, we use the Fluent interface comparison operators to: + +- Find high priority tasks by comparing the value of the ``priority`` property value with a threshold number, above which priority can be considered high. +- Find just-started or short-running tasks by seeing if the ``progressMinutes`` property falls within a certain range. +- Find unassigned tasks by finding tasks where the ``assignee`` property is equal to null. +- Find tasks assigned to specific teammates Ali or Jamie by seeing if the ``assignee`` property is in a list of names. + +.. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.filter-results.kt + :language: kotlin + :copyable: false + +Filter Data with RQL +```````````````````` + +To filter data with RQL, use :java-sdk:`RealmQuery.rawPredicate() +`. +For more information about syntax, usage and limitations, +refer to the :ref:`Realm Query Language reference `. + +RQL can use either the class and property names defined in your SDK model +classes or the internal names defined with ``@RealmField``. You can combine +raw predicates with other raw predicates or type-safe predicates created with +``RealmQuery``. diff --git a/source/includes/api-details/java/crud/read-find-object-by-primary-key-not-supported.rst b/source/includes/api-details/java/crud/read-find-object-by-primary-key-not-supported.rst new file mode 100644 index 0000000000..05523e5708 --- /dev/null +++ b/source/includes/api-details/java/crud/read-find-object-by-primary-key-not-supported.rst @@ -0,0 +1,5 @@ +Java and Kotlin (Java SDK) do not provide a dedicated API to find an object by +primary key. Instead, you can perform a regular query for objects where the +primary key property matches the desired primary key value using the +:java-sdk:`RealmQuery.equalTo() +` method. diff --git a/source/includes/api-details/java/crud/read-intro-description.rst b/source/includes/api-details/java/crud/read-intro-description.rst new file mode 100644 index 0000000000..89139d092b --- /dev/null +++ b/source/includes/api-details/java/crud/read-intro-description.rst @@ -0,0 +1,4 @@ +:java-sdk:`Query operations ` return a +:java-sdk:`results collection `. These +collections are live, meaning they always contain the latest +results of the associated query. diff --git a/source/includes/api-details/java/crud/read-limit-description.rst b/source/includes/api-details/java/crud/read-limit-description.rst new file mode 100644 index 0000000000..a82a686588 --- /dev/null +++ b/source/includes/api-details/java/crud/read-limit-description.rst @@ -0,0 +1,3 @@ +In Java or Kotlin (Java SDK), call the :java-sdk:`limit() +` method with a ``long`` argument to +limit the number of query results. diff --git a/source/includes/api-details/java/crud/read-query-dictionary-properties-description.rst b/source/includes/api-details/java/crud/read-query-dictionary-properties-description.rst new file mode 100644 index 0000000000..565bb4e3be --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-dictionary-properties-description.rst @@ -0,0 +1,4 @@ +- Check if the dictionary contains an specific key: + :java-sdk:`containsKey() ` +- Check if the dictionary contains a specific value: + :java-sdk:`containsValue() ` \ No newline at end of file diff --git a/source/includes/api-details/java/crud/read-query-inverse-relationship-java-description.rst b/source/includes/api-details/java/crud/read-query-inverse-relationship-java-description.rst new file mode 100644 index 0000000000..6d7f3edb6f --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-inverse-relationship-java-description.rst @@ -0,0 +1,13 @@ +Consider the following relationship between classes ``Cat`` and +``Human``. In this example, all cats link to their human (or +multiple humans, if multiple human objects refer to the same cat). +Realm calculates the owners of each cat for you based on the field +name you provide to the ``@LinkingObjects`` annotation: + +.. include:: /examples/generated/java/sync/Cat.snippet.complete.java.rst + +.. include:: /examples/generated/java/sync/Human.snippet.complete.java.rst + +To query this relationship, use dot notation in a +:ref:`query ` to access any property +of the linked object. diff --git a/source/includes/api-details/java/crud/read-query-inverse-relationship-kotlin-description.rst b/source/includes/api-details/java/crud/read-query-inverse-relationship-kotlin-description.rst new file mode 100644 index 0000000000..0a458a470e --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-inverse-relationship-kotlin-description.rst @@ -0,0 +1,13 @@ +Consider the following relationship between classes ``Dog`` and +``Person``. In this example, all dogs link to their owner (or +multiple owners, if multiple person objects refer to the same dog). +Realm calculates the owners of each dog for you based on the field +name you provide to the ``@LinkingObjects`` annotation: + +.. include:: /examples/generated/java/sync/Dog.snippet.complete.kt.rst + +.. include:: /examples/generated/java/sync/Person.snippet.complete.kt.rst + +To query this relationship, use dot notation in a +:ref:`query ` to access any property +of the linked object. diff --git a/source/includes/api-details/java/crud/read-query-list-properties-description.rst b/source/includes/api-details/java/crud/read-query-list-properties-description.rst new file mode 100644 index 0000000000..c34f99165b --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-list-properties-description.rst @@ -0,0 +1,3 @@ +You can read, query, iterate over, and sort a :java-sdk:`RealmList +` similar to working with a :cpp-sdk:`RealmResults +` collection. diff --git a/source/includes/api-details/java/crud/read-query-mixed-properties-description.rst b/source/includes/api-details/java/crud/read-query-mixed-properties-description.rst new file mode 100644 index 0000000000..9b689bae1a --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-mixed-properties-description.rst @@ -0,0 +1,7 @@ +You can query a ``RealmAny`` field just like any other data type. +Operators that only work with certain types, such as :ref:`string +operators ` and arithmetic operators, ignore +values that do not contain that type. Negating such operators matches +values that do not contain the type. Type queries match the underlying +type, rather than ``RealmAny``. Arithmetic operators convert numeric +values implicitly to compare across types. diff --git a/source/includes/api-details/java/crud/read-query-set-properties-description.rst b/source/includes/api-details/java/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..7d40ca3bde --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-set-properties-description.rst @@ -0,0 +1,17 @@ +``RealmSet`` implements Java's ``Set`` interface, so it works just like the +built-in ``HashSet`` class, except managed ``RealmSet`` instances persist +their contents to a database instance. ``RealmSet`` instances that contain SDK +objects actually only store references to those objects, so deleting an +SDK object from a database instance also deletes that object from +any ``RealmSet`` instances that contain the object. + +Because ``RealmSet`` implements ``RealmCollection``, it has some useful +mathematical methods, such as ``sum``, ``min``, and ``max``. For a complete +list of available ``RealmSet`` methods, see: :java-sdk:`the RealmSet API +reference `. + +- Check if the set contains a specific object with + :java-sdk:`RealmSet.contains() ` +- Check if the set contains all of multiple objects with + :java-sdk:`RealmSet.containsAll() ` + diff --git a/source/includes/api-details/java/crud/read-query-to-one-relationship-java-description.rst b/source/includes/api-details/java/crud/read-query-to-one-relationship-java-description.rst new file mode 100644 index 0000000000..975fc4ee7e --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-to-one-relationship-java-description.rst @@ -0,0 +1,14 @@ +Consider the following relationship between classes ``Human`` and +``Cat``. This arrangement allows each human to own a single cat: + +.. literalinclude:: /examples/generated/java/sync/Human.snippet.complete.java + :language: java + :emphasize-lines: 12 + :copyable: false + +.. literalinclude:: /examples/generated/java/sync/Cat.snippet.complete.java + :language: java + :copyable: false + +To query this relationship, use dot notation in a :ref:`query +` to access any property of the linked object. diff --git a/source/includes/api-details/java/crud/read-query-to-one-relationship-kotlin-description.rst b/source/includes/api-details/java/crud/read-query-to-one-relationship-kotlin-description.rst new file mode 100644 index 0000000000..ed276dc831 --- /dev/null +++ b/source/includes/api-details/java/crud/read-query-to-one-relationship-kotlin-description.rst @@ -0,0 +1,14 @@ +Consider the following relationship between classes ``Person`` and +``Dog``. This arrangement allows each person to own a single dog: + +.. literalinclude:: /examples/generated/java/sync/Person.snippet.complete.kt + :language: kotlin + :emphasize-lines: 10 + :copyable: false + +.. literalinclude:: /examples/generated/java/sync/Dog.snippet.complete.kt + :language: kotlin + :copyable: false + +To query this relationship, use dot notation in a :ref:`query +` to access any propertyof the linked object: diff --git a/source/includes/api-details/java/crud/read-sdk-results-collections-description.rst b/source/includes/api-details/java/crud/read-sdk-results-collections-description.rst new file mode 100644 index 0000000000..e2fa45ef3f --- /dev/null +++ b/source/includes/api-details/java/crud/read-sdk-results-collections-description.rst @@ -0,0 +1,40 @@ +The SDK's :java-sdk:`RealmResults ` collection is +a class representing objects retrieved from queries. A ``RealmResults`` +collection represents the lazily-evaluated results of a query operation, and +has these characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from live objects, the results automatically update when the database + contents change. If they derive from frozen objects, they represent only a + snapshot and do not automatically update. +- You cannot manually initialize an empty ``Results`` set. Results can only + be initialized as the result of a query. + +The :java-sdk:`RealmResults ` class inherits from +:android:`AbstractList ` and behaves +in similar ways. For example, ``RealmResults`` are ordered, and you can +access the individual objects through an index. If a query has no +matches, the returned ``RealmResults`` object is a list of length +0, not a ``null`` object reference. + +**Iteration** + +Because SDK collections are live, objects may move as you iterate over a +collection. You can use snapshots to iterate over collections safely. + +**Adapters** + +The SDK offers adapters to help bind data to standard UI widgets. These +classes work with any class that implements the ``OrderedRealmCollection`` +interface, which includes the built-in ``RealmResults`` and ``RealmList`` +classes. + +.. important:: Adapters Require Managed Objects + + The SDK adapters only accept *managed* SDK object instances tied to a + database instance. To display non-managed objects, use the general-use + Android ``RecyclerView.Adapter`` for recycler views or ``ArrayAdapter`` + for list views. diff --git a/source/includes/api-details/java/crud/read-sort-description.rst b/source/includes/api-details/java/crud/read-sort-description.rst new file mode 100644 index 0000000000..392eb02406 --- /dev/null +++ b/source/includes/api-details/java/crud/read-sort-description.rst @@ -0,0 +1,2 @@ +The following code sorts the projects by name in reverse +alphabetical order (i.e. "descending" order). diff --git a/source/includes/api-details/javascript/crud/read-access-results-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-access-results-js-ts-description.rst new file mode 100644 index 0000000000..520a965188 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-access-results-js-ts-description.rst @@ -0,0 +1,21 @@ +The ``Realm.Results`` type provides convenience functions to work with query +results. You may want to: + +- Check the :js-sdk:`.length ` of a + results set. +- Check whether the results set :js-sdk:`.isEmpty() + `. +- Check whether the results set :js-sdk:`.includes() + ` an individual element. +- Find the :js-sdk:`indexOf() ` + an element. +- :js-sdk:`find() ` + an element matching a predicate. + +For the full range of available functions to work with the results set, +refer to the the :js-sdk:`Realm.Results ` API +reference. + +Additionally, you can iterate through the results, or observe a results +set for changes. For more details about observing the results for changes, +refer to :ref:`sdks-react-to-changes`. diff --git a/source/includes/api-details/javascript/crud/read-aggregate-description.rst b/source/includes/api-details/javascript/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..7f2ebdbc40 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-aggregate-description.rst @@ -0,0 +1,4 @@ +In JavaScript, you perform aggregations through the :js-sdk:`filtered() +` method. In the ``filtered()`` method's +argument, use :ref:`Realm Query Language aggregate operators +` to aggregate data. diff --git a/source/includes/api-details/javascript/crud/read-all-objects-of-type-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-all-objects-of-type-js-ts-description.rst new file mode 100644 index 0000000000..8dcef82706 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-all-objects-of-type-js-ts-description.rst @@ -0,0 +1,5 @@ +To query for objects of a given type in a realm, pass the type name to +:js-sdk:`Realm.objects() `. + +Query operations return a collection of SDK objects that match the +query as a :js-sdk:`Realm.Results ` object. diff --git a/source/includes/api-details/javascript/crud/read-database-objects-js-ts-procedure.rst b/source/includes/api-details/javascript/crud/read-database-objects-js-ts-procedure.rst new file mode 100644 index 0000000000..ce63473c8e --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-database-objects-js-ts-procedure.rst @@ -0,0 +1,24 @@ +To find objects stored within a database: + +1. Query for objects of a given type in the database. Pass the object type + to the :js-sdk:`Realm.objects() ` method. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Work with the results. Objects may be frozen or live, depending on whether + you queried a frozen or live database, collection, or object. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection reference the matched objects, which +map directly to data in the database file. This also means that you can +traverse your graph of an object's :ref:`relationships ` +directly through the results of a query. diff --git a/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-box-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-box-js-ts-description.rst new file mode 100644 index 0000000000..f6fc39e678 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-box-js-ts-description.rst @@ -0,0 +1,3 @@ +A :js-sdk:`GeoBox ` is a rectangular shape whose +bounds are determined by :js-sdk:`GeoPoint ` +coordinates for a bottom-left and a top-right corner. diff --git a/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-circle-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-circle-js-ts-description.rst new file mode 100644 index 0000000000..6a8ca00f43 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-circle-js-ts-description.rst @@ -0,0 +1,8 @@ +A :js-sdk:`GeoCircle ` is a +circular shape whose bounds originate from a central :js-sdk:`GeoPoint +`, and has a size corresponding to +a ``distance`` radius measured in radians. You can use the SDK's convenience +methods to convert kilometers and miles to radians: + +- :js-sdk:`kmToRadians() ` +- :js-sdk:`miToRadians() ` diff --git a/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-polygon-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-polygon-js-ts-description.rst new file mode 100644 index 0000000000..fc6c36d3d7 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-define-geospatial-shapes-polygon-js-ts-description.rst @@ -0,0 +1,13 @@ +A :js-sdk:`GeoPolygon ` is a polygon +shape whose bounds consist of an outer ring, and 0 or more inner holes +to exclude from the geospatial query. + +A polygon's outer ring must contain at least three segments. The last +and the first :js-sdk:`GeoPoint ` +must be the same, which indicates a closed polygon. This means that it takes +at least four ``GeoPoint`` values to construct a polygon. + +Inner holes in a ``GeoPolygon`` are optional, and must be entirely contained +within the outer ring. Each ``GeoPoint`` collection in the ``holes?`` +collection must contain at least three segments, with the same rules as the +outer ring. diff --git a/source/includes/api-details/javascript/crud/read-filter-full-text-search-property-description.rst b/source/includes/api-details/javascript/crud/read-filter-full-text-search-property-description.rst new file mode 100644 index 0000000000..4ee2ab31bd --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-filter-full-text-search-property-description.rst @@ -0,0 +1,2 @@ +To query an FTS indexed property, use the ``TEXT`` predicate in your +:js-sdk:`filtered ` query. diff --git a/source/includes/api-details/javascript/crud/read-filter-or-query-objects-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-filter-or-query-objects-js-ts-description.rst new file mode 100644 index 0000000000..9fe9e3349c --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-filter-or-query-objects-js-ts-description.rst @@ -0,0 +1,10 @@ +To filter a query, call :js-sdk:`filtered() +` on a collection. Pass a Realm Query Language +query as argument to ``filtered()``. + +In the following example, we use RQL comparison operators to: + +- Find high priority tasks by comparing the value of the ``priority`` property + value with a threshold number, above which priority can be considered high. +- Find just-started or short-running tasks by seeing if the ``progressMinutes`` + property falls within a certain range. diff --git a/source/includes/api-details/javascript/crud/read-find-object-by-primary-key-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-find-object-by-primary-key-js-ts-description.rst new file mode 100644 index 0000000000..1e77bca21e --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-find-object-by-primary-key-js-ts-description.rst @@ -0,0 +1,2 @@ +To find an object by its primary key, call :js-sdk:`Realm.objectForPrimaryKey() +`. diff --git a/source/includes/api-details/javascript/crud/read-intro-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-intro-js-ts-description.rst new file mode 100644 index 0000000000..dfc59897d8 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-intro-js-ts-description.rst @@ -0,0 +1,6 @@ +Query operations return a :js-sdk:`results collection `. +Results collections may be either live or frozen. + +- **Live results** always contain the latest results of the associated query. +- **Frozen results** represent a snapshot that cannot be modified and doesn't + reflect the latest changes to the database. diff --git a/source/includes/api-details/javascript/crud/read-query-dictionary-properties-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-query-dictionary-properties-js-ts-description.rst new file mode 100644 index 0000000000..fcf7d72cfe --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-query-dictionary-properties-js-ts-description.rst @@ -0,0 +1,11 @@ +To filter a query, run :js-sdk:`collection.filtered() +` to specify a subset of results +based on the value(s) of one or more object properties. You can specify +results based on the value of a dictionary's properties by using +:mdn:`bracket-notation `. + +You can also determine whether a results collection has a certain key or value +by using ``.@keys`` or ``.@values``. For instance, if +you had a ``Person`` collection with a nested ``home`` dictionary, you could +return all ``Person`` objects with a ``home`` with a ``"price"`` property by +running the query: ``home.@keys = "price"``. diff --git a/source/includes/api-details/javascript/crud/read-query-geospatial-data-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-query-geospatial-data-js-ts-description.rst new file mode 100644 index 0000000000..ca710bb6cb --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-query-geospatial-data-js-ts-description.rst @@ -0,0 +1,15 @@ +The SDK provides specialized non-persistable data types to define shapes: + +- :js-sdk:`GeoPoint `: A type that represents the + coordinates of a point. A ``GeoPoint`` can be one of three types: + + - An object with: + + - Latitude: a number value. + - Longitude: a number value. + - Altitude: an optional number value. + - :js-sdk:`CanonicalGeoPoint + `: an interface that satisfies the + GeoJSON specifications for a point. + - :js-sdk:`GeoPosition `: an array with + longitude, latitude, and an optional altitude. diff --git a/source/includes/api-details/javascript/crud/read-query-inverse-relationship-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-query-inverse-relationship-js-ts-description.rst new file mode 100644 index 0000000000..58dfca970d --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-query-inverse-relationship-js-ts-description.rst @@ -0,0 +1,10 @@ +You can dynamically retrieve an object with an inverse relationship without +defining a ``linkingObjects`` type in its schema. When you need to retrieve +the linked object, call the :js-sdk:`Realm.Object.linkingObjects() +` query. + +The ``.linkingObjects()`` method returns a :ref:`Results collection +` of objects whose property inverts the relationship. + +In this example, only one manufacturer makes the Sentra car model, so we +can expect that manufacturer to be named Nissan. diff --git a/source/includes/api-details/javascript/crud/read-query-list-properties-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-query-list-properties-js-ts-description.rst new file mode 100644 index 0000000000..9dc327f741 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-query-list-properties-js-ts-description.rst @@ -0,0 +1,3 @@ +You can read, query, and sort a :js-sdk:`List +` similar to working with a :js-sdk:`results +` collection. diff --git a/source/includes/api-details/javascript/crud/read-query-mixed-properties-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-query-mixed-properties-js-ts-description.rst new file mode 100644 index 0000000000..8ac6c5d041 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-query-mixed-properties-js-ts-description.rst @@ -0,0 +1,5 @@ +Query for objects with a mixed value by running the +:js-sdk:`Collection.filtered() ` +method and passing in a :ref:`filter ` for a non-mixed +field. You can then print the value of the mixed property or the entire +object itself. diff --git a/source/includes/api-details/javascript/crud/read-query-set-properties-description.rst b/source/includes/api-details/javascript/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..709f9b63d3 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-query-set-properties-description.rst @@ -0,0 +1,29 @@ +Sets allow you to perform math operations such as finding the union, +intersection, or difference between two sets. To learn more about performing +these operations, see the MDN docs for :mdn:`Implementing basic set operations +`. + +To determine if a set contains a particular value, pass the value to the +``.has()`` method. The ``set.has()`` method will return true if the +set contains the value specified. + +.. literalinclude:: /examples/generated/node/data-types.snippet.check-if-set-has-items.js + :language: javascript + +To discover how many items are in a set, you can check the set's ``size`` +property. + +.. literalinclude:: /examples/generated/node/data-types.snippet.check-set-size.js + :language: javascript + +To traverse a set, use the ``.forEach()`` method or alternative +:mdn:`iteration method +`. + +.. literalinclude:: /examples/generated/node/data-types.snippet.traverse-a-set.js + :language: javascript + +The order of the **Realm.Set** may be different from the order that the items +were added. + +You can track the set order by updating an array when a new value is added. diff --git a/source/includes/api-details/javascript/crud/read-query-with-geospatial-shapes-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-query-with-geospatial-shapes-js-ts-description.rst new file mode 100644 index 0000000000..6517c73d15 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-query-with-geospatial-shapes-js-ts-description.rst @@ -0,0 +1,5 @@ +You can query geospatial data using the :ref:`Realm Query Language +` ``geoWithin`` operator. + +The examples below show the results of queries using these two ``Company`` +objects. diff --git a/source/includes/api-details/javascript/crud/read-sdk-results-collections-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-sdk-results-collections-js-ts-description.rst new file mode 100644 index 0000000000..191d943194 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-sdk-results-collections-js-ts-description.rst @@ -0,0 +1,14 @@ +The SDK's :js-sdk:`Results ` collection is +a class representing objects retrieved from queries. A ``Results`` collection +represents the lazily-evaluated results of a query operation, and has these +characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from live objects, the results automatically update when the database + contents change. If they derive from frozen objects, they represent only a + snapshot and do not automatically update. +- You cannot manually initialize an empty ``Results`` set. Results can only + be initialized as the result of a query. diff --git a/source/includes/api-details/javascript/crud/read-sort-js-ts-description.rst b/source/includes/api-details/javascript/crud/read-sort-js-ts-description.rst new file mode 100644 index 0000000000..2fbe1a6c98 --- /dev/null +++ b/source/includes/api-details/javascript/crud/read-sort-js-ts-description.rst @@ -0,0 +1,2 @@ +To sort a query, call the :js-sdk:`sorted() ` +method on the query results collection. diff --git a/source/includes/api-details/kotlin/crud/read-access-results-description.rst b/source/includes/api-details/kotlin/crud/read-access-results-description.rst new file mode 100644 index 0000000000..e826b4b301 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-access-results-description.rst @@ -0,0 +1,42 @@ +In Kotlin, the ``RealmResults`` type provides convenience functions to work +with query results. You may want to: + +- Check the :kotlin-sdk:`.size + ` + of a results set. +- Check whether the results set :kotlin-sdk:`.isEmpty() + `. +- Check whether the results set :kotlin-sdk:`.contains() + ` + an individual element or :kotlin-sdk:`.containsAll() + ` + the elements in a collection. +- Find the :kotlin-sdk:`indexOf() + ` + an element. +- :kotlin-sdk:`get() + ` + the element at an index. +- Get the ``.first()`` element in the results set. + +For the full range of available functions to work with the results set, +refer to the the :kotlin-sdk:`RealmResults +` API reference. + +Additionally, you can iterate through the results, or observe a results +set for changes. For more details about observing the results for changes, +refer to :ref:`sdks-react-to-changes`. + +Iterate Results using Flow +++++++++++++++++++++++++++ + +You can iterate through results using a +`Kotlin Coroutine Flow `__. + +To convert query results into an asynchronous ``Flow``, call +:kotlin-sdk:`asFlow() ` +on the query. The SDK returns a :kotlin-sdk:`ResultsChange ` +``Flow`` that you can iterate through with +`flow.collect() `__. + +In the following example, we iterate through a ``Flow`` of ``Frog`` objects. diff --git a/source/includes/api-details/kotlin/crud/read-aggregate-description.rst b/source/includes/api-details/kotlin/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..a52243c6cf --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-aggregate-description.rst @@ -0,0 +1,11 @@ +You can perform aggregation using +:ref:`RQL aggregate operators `, one of the +following convenience methods, or a combination of both: + +- :kotlin-sdk:`max() ` +- :kotlin-sdk:`min() ` +- :kotlin-sdk:`sum() ` +- :kotlin-sdk:`count() ` + +In the following example, we aggregate the ``age`` property of a ``Frog`` +object type. diff --git a/source/includes/api-details/kotlin/crud/read-all-objects-of-type-description.rst b/source/includes/api-details/kotlin/crud/read-all-objects-of-type-description.rst new file mode 100644 index 0000000000..25ea6f3549 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-all-objects-of-type-description.rst @@ -0,0 +1,4 @@ +To query all objects of a specific type, pass the ``RealmObject`` or +``EmbeddedRealmObject`` object type as a type parameter to +:kotlin-sdk:`query() ` without any query +arguments. The SDK returns all objects of the specified type. diff --git a/source/includes/api-details/kotlin/crud/read-database-objects-procedure.rst b/source/includes/api-details/kotlin/crud/read-database-objects-procedure.rst new file mode 100644 index 0000000000..49d429e477 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-database-objects-procedure.rst @@ -0,0 +1,48 @@ +To find objects stored within a database: + +1. Construct queries using the SDK's query builder + :kotlin-sdk:`RealmQuery `. + Call the :kotlin-sdk:`query() ` method, + passing the object type as the type parameter. The object type must be + included in your database schema. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. + + Chain filters by appending additional ``query()`` methods to the + ``RealmQuery``. Each appended ``query()`` acts as an ``AND`` query + condition. Because of the SDK's lazy evaluation, chaining queries does + not require separate trips to the database. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Execute the query using either: + + - :kotlin-sdk:`find() ` for synchronous + queries. Returns a collection of results. + - :kotlin-sdk:`asFlow() ` + for asynchronous queries. Subscribes to a ``Flow`` of results changes. + + .. tip:: Prefer ``asFlow()`` for Large Data Sets + + ``find()`` runs a synchronous query on the thread it is called from. + As a result, avoid using ``find()`` for large data sets on the UI thread + or in logic that could delay the UI thread. + + Prefer ``asFlow()`` to prevent negative performance or UI impact. + +#. Work with the results. Objects may be frozen or live, depending on the + type of query you ran. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection or flow reference the matched +objects, which map directly to data in the database file. This also means +that you can traverse your graph of an object's +:ref:`relationships ` directly through the results +of a query. diff --git a/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-box-description.rst b/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-box-description.rst new file mode 100644 index 0000000000..dc1677a492 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-box-description.rst @@ -0,0 +1,4 @@ +A :kotlin-sdk:`GeoBox ` is a +rectangular shape whose bounds are determined by :kotlin-sdk:`GeoPoint +` coordinates for a bottom-left +and a top-right corner. diff --git a/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-circle-description.rst b/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-circle-description.rst new file mode 100644 index 0000000000..1664c6e97f --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-circle-description.rst @@ -0,0 +1,18 @@ +A :kotlin-sdk:`GeoCircle ` is +a circular shape whose bounds originate from a central :kotlin-sdk:`GeoPoint +`, and has a size +corresponding to a radius measured in radians. You can use the SDK's +convenience :kotlin-sdk:`Distance +` class to easily work with +radii in different units. + +You can use the following convenience methods to create a ``GeoDistance`` from +different measures: + +- ``GeoDistance.fromDegrees(double degrees)`` +- ``GeoDistance.fromKilometers(double kilometers)`` +- ``GeoDistance.fromMiles(double miles)`` +- ``GeoDistance.fromRadians(double radians)`` + +You can optionally access the distance value in any of these units, represented +as a double. diff --git a/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-polygon-description.rst b/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-polygon-description.rst new file mode 100644 index 0000000000..37d849731e --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-define-geospatial-shapes-polygon-description.rst @@ -0,0 +1,13 @@ +A :kotlin-sdk:`GeoPolygon ` +is a polygon shape whose bounds consist of an outer ring, and 0 or more inner +holes to exclude from the geospatial query. + +A polygon's outer ring must contain at least three segments. The last +and the first :kotlin-sdk:`GeoPoint +` must be the same, which +indicates a closed polygon. This means that it takes at least four ``GeoPoint`` +values to construct a polygon. + +Inner holes in a ``GeoPolygon`` are optional, and must be entirely contained +within the outer ring. Each ``GeoPoint`` collection in the ``Holes`` collection +must contain at least three segments, with the same rules as the outer ring. diff --git a/source/includes/api-details/kotlin/crud/read-filter-by-remapped-property-name-description.rst b/source/includes/api-details/kotlin/crud/read-filter-by-remapped-property-name-description.rst new file mode 100644 index 0000000000..455583ad20 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-filter-by-remapped-property-name-description.rst @@ -0,0 +1,8 @@ +In the following example, the ``Frog`` object has a property named ``species`` +in the code that is remapped to ``latin_name`` in the database: + +.. literalinclude:: /examples/generated/kotlin/Schema.snippet.define-persisted-name.kt + :language: kotlin + +In the database, we can filter by either property name and return the same +results. diff --git a/source/includes/api-details/kotlin/crud/read-filter-full-text-search-property-description.rst b/source/includes/api-details/kotlin/crud/read-filter-full-text-search-property-description.rst new file mode 100644 index 0000000000..7b804fe12d --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-filter-full-text-search-property-description.rst @@ -0,0 +1,3 @@ +In the following example, the ``Frog`` object type has an FTS index property +called ``physicalDescription`` that we can filter by to find different types +of frogs. diff --git a/source/includes/api-details/kotlin/crud/read-filter-or-query-objects-description.rst b/source/includes/api-details/kotlin/crud/read-filter-or-query-objects-description.rst new file mode 100644 index 0000000000..4ac65ac579 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-filter-or-query-objects-description.rst @@ -0,0 +1,8 @@ +To filter by property, you can pass Realm Query Language (RQL) filters and +operators, use Kotlin's built-in extension methods or the SDK's convenience +methods, or use a combination. + +In the following example, we :kotlin-sdk:`query() +` a ``Frog`` object type and +filter by the ``name`` property. We call the ``find()`` method to execute +the query. diff --git a/source/includes/api-details/kotlin/crud/read-find-object-by-primary-key-not-supported.rst b/source/includes/api-details/kotlin/crud/read-find-object-by-primary-key-not-supported.rst new file mode 100644 index 0000000000..ca313e980a --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-find-object-by-primary-key-not-supported.rst @@ -0,0 +1,6 @@ +Kotlin does not provide a dedicated API to find an object by its primary key. +Instead, you can perform a regular query for objects where the primary +key property matches the desired primary key value. + +In the following example, we query a ``Frog`` object and filter by the primary +key property ``_id``. diff --git a/source/includes/api-details/kotlin/crud/read-intro-description.rst b/source/includes/api-details/kotlin/crud/read-intro-description.rst new file mode 100644 index 0000000000..88bbae9c9b --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-intro-description.rst @@ -0,0 +1,7 @@ +Query operations return a :kotlin-sdk:`results collection +`. Results collections may be +either live or frozen. + +- **Live results** always contain the latest results of the associated query. +- **Frozen results** represent a snapshot that cannot be modified and doesn't + reflect the latest changes to the database. diff --git a/source/includes/api-details/kotlin/crud/read-limit-description.rst b/source/includes/api-details/kotlin/crud/read-limit-description.rst new file mode 100644 index 0000000000..88b1384a30 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-limit-description.rst @@ -0,0 +1,3 @@ +You can specify a limit using :ref:`RQL ` or +the SDK convenience method :kotlin-sdk:`limit() +`. diff --git a/source/includes/api-details/kotlin/crud/read-query-dictionary-properties-description.rst b/source/includes/api-details/kotlin/crud/read-query-dictionary-properties-description.rst new file mode 100644 index 0000000000..a09443c3de --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-dictionary-properties-description.rst @@ -0,0 +1,7 @@ +You can query and iterate through a :ref:`RealmDictionary ` +property as you would a +`Kotlin Map `__. + +In the following example, we query a ``RealmDictionary`` property called +``favoritePondsByForest``, which maps a ``String`` key (forest) to a +``String`` value (pond). diff --git a/source/includes/api-details/kotlin/crud/read-query-geospatial-data-description.rst b/source/includes/api-details/kotlin/crud/read-query-geospatial-data-description.rst new file mode 100644 index 0000000000..1aa6ddcc0c --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-geospatial-data-description.rst @@ -0,0 +1,13 @@ +The SDK provides two specialized non-persistable data types to define shapes: + +- :kotlin-sdk:`GeoPoint `: An + interface that represents the coordinates of a point formed by a pair of + doubles consisting of these values: + + - Latitude: ranges between -90 and 90 degrees, inclusive. + - Longitude: ranges between -180 and 180 degrees, inclusive. +- :kotlin-sdk:`Distance `: A + class that represents a distance used to calculate the size of the + circle shape. ``Distance`` provides convenience methods to simplify + converting degrees, kilometers, miles, and radians to and from the + ``Distance`` measure. diff --git a/source/includes/api-details/kotlin/crud/read-query-inverse-relationship-description.rst b/source/includes/api-details/kotlin/crud/read-query-inverse-relationship-description.rst new file mode 100644 index 0000000000..e9e07180fc --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-inverse-relationship-description.rst @@ -0,0 +1,13 @@ +In the following example, a parent object of type ``User`` has an inverse +relationship to a child object of type ``Post``. We can query the parent +object's ``User.posts`` relationship ("User has many Posts") as well +as the inverse ``Post.user`` relationship ("Post belongs to User"): + +.. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-inverse-relationship.kt + :language: kotlin + +.. important:: Querying Inverse Relationship by Remapped Class Names + + If the inverse relationship property is an object type with a + remapped (persisted) class name, you *must* use the remapped class + name in the raw RQL query. diff --git a/source/includes/api-details/kotlin/crud/read-query-list-properties-description.rst b/source/includes/api-details/kotlin/crud/read-query-list-properties-description.rst new file mode 100644 index 0000000000..3a92364577 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-list-properties-description.rst @@ -0,0 +1,6 @@ +You can query and iterate through a :ref:`RealmList ` +property as you would a +`Kotlin List `__. + +In the following example, we query a ``RealmList`` property called +``favoritePonds``. diff --git a/source/includes/api-details/kotlin/crud/read-query-mixed-properties-description.rst b/source/includes/api-details/kotlin/crud/read-query-mixed-properties-description.rst new file mode 100644 index 0000000000..237faa0173 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-mixed-properties-description.rst @@ -0,0 +1,37 @@ +In the following example, we query a ``RealmAny`` property called +``favoriteThing`` for a frog with a favorite thing of type ``Int``: + +.. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-realmany-property.kt + :language: kotlin + +Unlike other properties, you must extract a ``RealmAny`` property's stored +value before you can work with it. To extract the value, use +the SDK's getter method for the stored type. If you use the wrong getter for +the type, the SDK throws an exception. + +A best practice is to use a conditional expression to get the currently stored +type with :kotlin-sdk:`RealmAny.type() `, +then extract the value based on the type. For a full list of getter +methods, refer to the :kotlin-sdk:`RealmAny +` API reference. + +.. tip:: Handle Polymorphism with Conditional Expressions + + Use a conditional ``when`` expression to handle the possible inner value + class of a given ``RealmAny`` property: + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.polymorphism.kt + :language: kotlin + +Once you have the currently stored value, you can work with it the same way you +would another value of that type. + +.. note:: + + ``Byte``, ``Char``, ``Int``, ``Long``, and ``Short`` values are converted + internally to ``int64_t`` values. Keep this in mind when comparing, + sorting, or aggregating ``RealmAny`` values of these types. + +In the following example, we extract the value using +:kotlin-sdk:`RealmAny.asInt() ` +since we know the returned frog's favorite thing is an ``Int`` type value. diff --git a/source/includes/api-details/kotlin/crud/read-query-set-properties-description.rst b/source/includes/api-details/kotlin/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..877e86e46e --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-set-properties-description.rst @@ -0,0 +1,6 @@ +You can query and iterate through a :ref:`RealmSet ` +property as you would a +`Kotlin Set `__. + +In the following example, we query a ``RealmSet`` property called +``favoriteSnacks``. diff --git a/source/includes/api-details/kotlin/crud/read-query-to-many-relationship-description.rst b/source/includes/api-details/kotlin/crud/read-query-to-many-relationship-description.rst new file mode 100644 index 0000000000..525cca271a --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-to-many-relationship-description.rst @@ -0,0 +1,2 @@ +In the following example, the ``Forest`` object type has a property called +``nearbyPonds`` that is a ``RealmList`` of type ``Pond``. diff --git a/source/includes/api-details/kotlin/crud/read-query-to-one-relationship-description.rst b/source/includes/api-details/kotlin/crud/read-query-to-one-relationship-description.rst new file mode 100644 index 0000000000..5ef8210c61 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-to-one-relationship-description.rst @@ -0,0 +1,2 @@ +In the following example, the ``Frog`` object type has a property called +``favoritePond`` of type ``Pond``. diff --git a/source/includes/api-details/kotlin/crud/read-query-with-geospatial-shapes-description.rst b/source/includes/api-details/kotlin/crud/read-query-with-geospatial-shapes-description.rst new file mode 100644 index 0000000000..6517c73d15 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-query-with-geospatial-shapes-description.rst @@ -0,0 +1,5 @@ +You can query geospatial data using the :ref:`Realm Query Language +` ``geoWithin`` operator. + +The examples below show the results of queries using these two ``Company`` +objects. diff --git a/source/includes/api-details/kotlin/crud/read-sdk-results-collections-description.rst b/source/includes/api-details/kotlin/crud/read-sdk-results-collections-description.rst new file mode 100644 index 0000000000..0c1b7b65d7 --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-sdk-results-collections-description.rst @@ -0,0 +1,17 @@ +The SDK's :kotlin-sdk:`RealmResults +` collection is a class +representing objects retrieved from queries. A ``RealmResults`` collection +represents the lazily-evaluated results of a query operation, and has these +characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from a query on a :kotlin-sdk:`MutableRealm + `, the results automatically + update when the database contents on the thread change. If they derive from + a query on a :kotlin-sdk:`Realm `, they + represent only a snapshot and do not automatically update. +- You cannot manually initialize an empty ``RealmResults`` set. Results can only + be initialized as the result of a query. diff --git a/source/includes/api-details/kotlin/crud/read-sort-description.rst b/source/includes/api-details/kotlin/crud/read-sort-description.rst new file mode 100644 index 0000000000..8a4740914d --- /dev/null +++ b/source/includes/api-details/kotlin/crud/read-sort-description.rst @@ -0,0 +1,3 @@ +You can specify a sort order using :ref:`RQL ` or +the SDK convenience method :kotlin-sdk:`sort() +`. diff --git a/source/includes/api-details/kotlin/model-data/object-models-map-model-or-property-to-different-name-description.rst b/source/includes/api-details/kotlin/model-data/object-models-map-model-or-property-to-different-name-description.rst index f00104b3b8..4a43849772 100644 --- a/source/includes/api-details/kotlin/model-data/object-models-map-model-or-property-to-different-name-description.rst +++ b/source/includes/api-details/kotlin/model-data/object-models-map-model-or-property-to-different-name-description.rst @@ -23,7 +23,7 @@ persisted name to used to store objects in the database: In the example above, you must query ``Frog_Entity`` instead of ``Frog``. For more information, refer to :ref:`Query Inverse Relationships - `. + `. **Map a Property Name** diff --git a/source/includes/api-details/objectivec/crud/read-access-results-description.rst b/source/includes/api-details/objectivec/crud/read-access-results-description.rst new file mode 100644 index 0000000000..07207cc700 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-access-results-description.rst @@ -0,0 +1,21 @@ +The ``RLMResults`` type provides convenience functions to work with query +results. You may want to: + +- Check the :objc-sdk:`.count + ` of a results set. +- Find the :objc-sdk:`-indexOfObject: + ` + for an object. +- Get the :objc-sdk:`-objectAtIndex: + `. +- Get the :objc-sdk:`-firstObject + ` or + :objc-sdk:`-lastObject + ` in the + results set. + +For the full range of available functions to work with the results set, +refer to the the :objc-sdk:`RLMResults ` API reference. + +Additionally, you can observe a results set for changes. For more details +about observing the results for changes, refer to :ref:`sdks-react-to-changes`. diff --git a/source/includes/api-details/objectivec/crud/read-aggregate-description.rst b/source/includes/api-details/objectivec/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..7b64f7b268 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-aggregate-description.rst @@ -0,0 +1,7 @@ +In Objective-C, you can perform aggregations with these methods: + +- :objc-sdk:`count ` +- :objc-sdk:`-minOfProperty ` +- :objc-sdk:`-maxOfProperty ` +- :objc-sdk:`-sumOfProperty ` +- :objc-sdk:`-averageOfProperty ` diff --git a/source/includes/api-details/objectivec/crud/read-all-objects-of-type-description.rst b/source/includes/api-details/objectivec/crud/read-all-objects-of-type-description.rst new file mode 100644 index 0000000000..d6cc35e4a8 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-all-objects-of-type-description.rst @@ -0,0 +1,7 @@ +To query for objects of a given type in the database, pass the database +instance to :objc-sdk:`+[YourSDKObjectClass allObjectsInRealm:] +`. +Replace ``YourSDKObjectClass`` with your SDK object class +name. This returns an :objc-sdk:`RLMResults +` object representing all objects of the +given type in the database. diff --git a/source/includes/api-details/objectivec/crud/read-chain-queries-description.rst b/source/includes/api-details/objectivec/crud/read-chain-queries-description.rst new file mode 100644 index 0000000000..a506cd6b14 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-chain-queries-description.rst @@ -0,0 +1,2 @@ +To get a result set for tan dogs, and tan dogs whose names start with +'B', you can chain two queries. diff --git a/source/includes/api-details/objectivec/crud/read-database-objects-procedure.rst b/source/includes/api-details/objectivec/crud/read-database-objects-procedure.rst new file mode 100644 index 0000000000..cc984a641c --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-database-objects-procedure.rst @@ -0,0 +1,29 @@ +To find objects stored within a database: + +1. Query for objects of a given type in the database. Pass the object type + to the :objc-sdk:`RLMObject allObjects + ` method. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. You can use :objc-sdk:`RLMObject objectsWhere + ` or + :objc-sdk:`RLMObject objectsWithPredicate + ` + to get objects matching a query. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Work with the results. Objects may be frozen or live, depending on whether + you queried a frozen or live database, collection, or object. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection reference the matched objects, which +map directly to data in the database file. This also means that you can +traverse your graph of an object's :ref:`relationships ` +directly through the results of a query. diff --git a/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-box-description.rst b/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-box-description.rst new file mode 100644 index 0000000000..f643997ae6 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-box-description.rst @@ -0,0 +1,3 @@ +A :objc-sdk:`RLMGeospatialBox ` is a +rectangular shape whose bounds are determined by coordinates for a bottom-left +and a top-right corner. diff --git a/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-circle-description.rst b/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-circle-description.rst new file mode 100644 index 0000000000..b7b4cf517d --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-circle-description.rst @@ -0,0 +1,16 @@ +A ``GeoCircle`` is a circular shape whose bounds originate from a central +:objc-sdk:`RLMGeospatialPoint `, and has a +size corresponding to a radius measured in radians. You can use the SDK's +convenience :objc-sdk:`RLMDistance ` object to +easily work with radii in different units. + +``RLMDistance`` enables you to specify the radius distance for your geo shapes +in one of four units: + +- Radians +- Degrees +- Miles +- Kilometers + +You can use the supplied convenience methods to convert a measurement to +different distance units. diff --git a/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-polygon-description.rst b/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-polygon-description.rst new file mode 100644 index 0000000000..39668151c8 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-define-geospatial-shapes-polygon-description.rst @@ -0,0 +1,11 @@ +A :objc-sdk:`RLMGeospatialPolygon ` is a +polygon shape whose bounds consist of an outer ring, and 0 or more inner holes +to exclude from the geospatial query. + +A polygon's outer ring must contain at least three segments. The last +and the first :objc-sdk:`RLMGeospatialPoint ` +must be the same, which indicates a closed polygon. This means that it takes +at least four ``RLMGeospatialPoint`` values to construct a polygon. + +Inner holes in a ``RLMGeospatialPolygon`` must be entirely contained within the +outer ring. diff --git a/source/includes/api-details/objectivec/crud/read-filter-or-query-objects-description.rst b/source/includes/api-details/objectivec/crud/read-filter-or-query-objects-description.rst new file mode 100644 index 0000000000..c2d80e9938 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-filter-or-query-objects-description.rst @@ -0,0 +1,6 @@ +To filter results in Objective-C, call :objc-sdk:`-[RLMResults objectsWhere:] +` +with a query predicate. + +For more details about the supported operators available for Objective-C +queries, refer to :ref:`sdks-filter-data-swift`. diff --git a/source/includes/api-details/objectivec/crud/read-find-object-by-primary-key-description.rst b/source/includes/api-details/objectivec/crud/read-find-object-by-primary-key-description.rst new file mode 100644 index 0000000000..eed7360e25 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-find-object-by-primary-key-description.rst @@ -0,0 +1,3 @@ +To find a specific object by primary key, call +:objc-sdk:`+[RLMObject objectForPrimaryKey:] +`. diff --git a/source/includes/api-details/objectivec/crud/read-intro-description.rst b/source/includes/api-details/objectivec/crud/read-intro-description.rst new file mode 100644 index 0000000000..a327ae83c3 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-intro-description.rst @@ -0,0 +1,8 @@ +Query operations return a :objc-sdk:`results collection +`. + +Results collections may be either live or frozen. + +- **Live results** always contain the latest results of the associated query. +- **Frozen results** represent a snapshot that cannot be modified and doesn't + reflect the latest changes to the database. diff --git a/source/includes/api-details/objectivec/crud/read-limit-not-supported.rst b/source/includes/api-details/objectivec/crud/read-limit-not-supported.rst new file mode 100644 index 0000000000..69564d06c8 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-limit-not-supported.rst @@ -0,0 +1,3 @@ +Objective-C does not provide an API to limit query results. Instead, rely on +the SDK's lazy loading characteristics to implicitly limit the objects in +memory by only accessing the objects you need for an operation. diff --git a/source/includes/api-details/objectivec/crud/read-query-custom-persistable-property-description.rst b/source/includes/api-details/objectivec/crud/read-query-custom-persistable-property-description.rst new file mode 100644 index 0000000000..f8053836b9 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-custom-persistable-property-description.rst @@ -0,0 +1,36 @@ +Queries on SDK Objects +`````````````````````` + +When working with projected types, queries operate on the persisted type. +However, you can use the mapped types interchangeably with the persisted +types in arguments in most cases. The exception is queries on embedded +objects. + +.. tip:: + + Projected types support :ref:`sorting and aggregates ` + where the persisted type supports them. + +Queries on Embedded Objects +``````````````````````````` + +You can query embedded types on the supported property types within the +object using memberwise equality. + +Object link properties support equality comparisons, but do not support +memberwise comparisons. You can query embedded objects for memberwise +equality on all primitive types. You cannot perform memberwise comparison +on objects and collections. + +Dynamic APIs +```````````` + +Because the schema has no concept of custom type mappings, reading data via +any of the dynamic APIs gives the underlying persisted type. The SDK does +support writing mapped types via a dynamic API, and converts the projected +type to the persisted type. + +The most common use of the dynamic APIs is migration. You can write projected +types during migration, and the SDK converts the projected type to the persisted +type. However, reading data during a migration gives the underlying persisted +type. diff --git a/source/includes/api-details/objectivec/crud/read-query-dictionary-properties-description.rst b/source/includes/api-details/objectivec/crud/read-query-dictionary-properties-description.rst new file mode 100644 index 0000000000..5b6292336e --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-dictionary-properties-description.rst @@ -0,0 +1,22 @@ +You can query a :objc-sdk:`RLMDictionary +` with the same predicates as :objc-sdk:`RLMObject +` and :objc-sdk:`RLMResults `. + +- Access :objc-sdk:`allKeys + ` or + :objc-sdk:`allValues + `. +- Get the :objc-sdk:`-objectForKey: + ` or + :objc-sdk:`-valueForKey: + `. +- Work with keys and objects using :objc-sdk:`-enumerateKeysAndObjectsUsingBlock: + `. + +.. tip:: RLMDictionary may contain keys whose values are nil + + An SDK map may contain keys with ``nil`` values. If you delete an object + that is used as a map value, the value is set to ``nil`` but the key + remains unless you explicitly delete it. If your app deletes map values + without also explicitly cleaning up the keys, you may need to perform + optional unwrapping when you read map values. diff --git a/source/includes/api-details/objectivec/crud/read-query-geospatial-data-description.rst b/source/includes/api-details/objectivec/crud/read-query-geospatial-data-description.rst new file mode 100644 index 0000000000..223b386910 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-geospatial-data-description.rst @@ -0,0 +1,11 @@ +The SDK provides two specialized non-persistable data types to define shapes: + +- :objc-sdk:`RLMGeospatialPoint `: A + class that represents the coordinates of a point formed by a pair of + doubles consisting of these values: + + - Latitude: ranges between -90 and 90 degrees, inclusive. + - Longitude: ranges between -180 and 180 degrees, inclusive. + - Altitude (optional): cannot be a negative value. +- :objc-sdk:`RLMDistance `: A helper to represent + and convert a distance. diff --git a/source/includes/api-details/objectivec/crud/read-query-inverse-relationship-description.rst b/source/includes/api-details/objectivec/crud/read-query-inverse-relationship-description.rst new file mode 100644 index 0000000000..7a09ac77d5 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-inverse-relationship-description.rst @@ -0,0 +1,7 @@ +You can query :swift-sdk:`RLMLinkingObjects +`, an auto-updating container type, +to access zero or more objects that are linked to its owning model object +through a property relationship. You can query ``RLMLinkingObjects`` with the +same APIs and predicates as +:swift-sdk:`RLMArray\ ` and +:swift-sdk:`RLMResults\ `. diff --git a/source/includes/api-details/objectivec/crud/read-query-list-properties-description.rst b/source/includes/api-details/objectivec/crud/read-query-list-properties-description.rst new file mode 100644 index 0000000000..3cfe844aac --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-list-properties-description.rst @@ -0,0 +1,3 @@ +You can query a :objc-sdk:`RLMArray ` with the same +predicates as :objc-sdk:`RLMResults ` and +:objc-sdk:`RLMObject `. diff --git a/source/includes/api-details/objectivec/crud/read-query-mixed-properties-description.rst b/source/includes/api-details/objectivec/crud/read-query-mixed-properties-description.rst new file mode 100644 index 0000000000..0335355dc2 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-mixed-properties-description.rst @@ -0,0 +1,21 @@ +When you read an :objc-sdk:`RLMValue ` +property, check the value's type before doing anything with it. The SDK +provides an :objc-sdk:`RLMAnyValueType enum ` that +iterates through all of the types the ``RLMValue`` can store. + +You can :ref:`compare ` these mixed +value types: + +- Numeric: int, bool, float, double, ``RLMDecimal128`` +- Byte-based: ``NSString``, ``NSData`` +- Time-based: ``NSDate``, ``RLMObjectId`` + +When using the ``RLMValue`` mixed data type, keep these things in mind: + +- ``equals`` queries match on value and type +- ``not equals`` queries match objects with either different values or + different types +- The SDK converts comparable numeric properties where possible. For example, + in a mixed type field, 1 matches all of 1.0, 1, and true. +- String properties do not match numeric queries. For example, in a mixed + type field, 1 does not match "1". "1" does not match 1, 1.0, or true. diff --git a/source/includes/api-details/objectivec/crud/read-query-projections-missing-description.rst b/source/includes/api-details/objectivec/crud/read-query-projections-missing-description.rst new file mode 100644 index 0000000000..b97e8cf74e --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-projections-missing-description.rst @@ -0,0 +1,2 @@ +The documentation does not currently have information for how to query +class projections in Objective-C. diff --git a/source/includes/api-details/objectivec/crud/read-query-set-properties-description.rst b/source/includes/api-details/objectivec/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..c05df4cfc9 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-set-properties-description.rst @@ -0,0 +1,4 @@ +You can query a :objc-sdk:`RLMSet ` to check if +it contains an element. If you are working with multiple sets, you can +check for the intersection of two sets, or check whether one set is a subset +of the other set. diff --git a/source/includes/api-details/objectivec/crud/read-query-with-geospatial-shapes-description.rst b/source/includes/api-details/objectivec/crud/read-query-with-geospatial-shapes-description.rst new file mode 100644 index 0000000000..0d38ffeb67 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-query-with-geospatial-shapes-description.rst @@ -0,0 +1,4 @@ +You can query geospatial data using :objc-sdk:`-objectsWithPredicate +` +with an :ref:`NSPredicate query ` that uses +``geoWithin``. diff --git a/source/includes/api-details/objectivec/crud/read-sdk-results-collections-description.rst b/source/includes/api-details/objectivec/crud/read-sdk-results-collections-description.rst new file mode 100644 index 0000000000..792ffe5972 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-sdk-results-collections-description.rst @@ -0,0 +1,26 @@ +The SDK's :objc-sdk:`RLMResults ` collection is +a class representing objects retrieved from queries. A ``RLMResults`` +collection represents the lazily-evaluated results of a query operation, and +has these characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from live objects, the results automatically update when the database + contents on the thread change. If they derive from frozen objects, they + represent only a snapshot and do not automatically update. +- You cannot manually initialize an empty ``RLMResults`` set. Results can only + be initialized as the result of a query. + +In Objective-C, the SDK also provides :objc-sdk:`RLMSectionedResults +`, a type-safe collection which holds +``RLMSection`` as its elements. Each :objc-sdk:`RLMSection +` is a collection that contains only +objects that belong to a given section key. + +For example, an app that includes a contact list might use RLMSectionedResults +to display a list of contacts divided into sections, where each section +contains all the contacts whose first name starts with the given letter. +The ``RLMSection`` whose key is "L" would contain "Larry", "Liam", +and "Lisa". diff --git a/source/includes/api-details/objectivec/crud/read-section-query-results-description.rst b/source/includes/api-details/objectivec/crud/read-section-query-results-description.rst new file mode 100644 index 0000000000..b353b80c80 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-section-query-results-description.rst @@ -0,0 +1,14 @@ +In Objective-C, you can create a :objc-sdk:`RLMSectionedResults +` type-safe collection in two ways: + +- Using a keyPath: :objc-sdk:`-sectionedResultsSortedUsingKeyPath:ascending:keyBlock: + ` +- Using a sort descriptor: :objc-sdk:`-sectionedResultsUsingSortDescriptors:keyBlock: + ` + +You can get a count of the sections, get a list of keys, or access an individual +:objc-sdk:`RLMSectionedResult segment ` by +key or index. + +You can :ref:`observe ` ``RLMSectionedResults`` and +``RLMSectionedResult`` instances. diff --git a/source/includes/api-details/objectivec/crud/read-sort-description.rst b/source/includes/api-details/objectivec/crud/read-sort-description.rst new file mode 100644 index 0000000000..d16dc9ae73 --- /dev/null +++ b/source/includes/api-details/objectivec/crud/read-sort-description.rst @@ -0,0 +1,4 @@ +To sort, call :objc-sdk:`-[RLMResults +sortedResultsUsingKeyPath:ascending:] +` +with the desired key path to sort by. diff --git a/source/includes/api-details/swift/crud/read-access-results-description.rst b/source/includes/api-details/swift/crud/read-access-results-description.rst new file mode 100644 index 0000000000..53660fc0b7 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-access-results-description.rst @@ -0,0 +1,23 @@ +The :swift-sdk:`Results ` type implements the +:swift-sdk:`RealmCollection ` protocol, which +provides convenience properties and functions to work with query results. You +may want to: + +- Check the :swift-sdk:`.count + ` + of the number of objects in a results set. +- Check whether the results set ``.isEmpty()``. +- Check whether the results set :swift-sdk:`.contains(where: Predicate) + ` + an object satisfying a predicate. +- Find the ``.firstIndex(of: )`` or ``.lastIndex(of: )`` a given object. +- Get the ``.firstWhere(Predicate)`` to get the first object in the collection + matching the given predicate. +- Get the :swift-sdk:`.first + ` + or :swift-sdk:`.last + ` + element in the results set. + +Additionally, you can observe a results set for changes. For more details +about observing the results for changes, refer to :ref:`sdks-react-to-changes`. diff --git a/source/includes/api-details/swift/crud/read-aggregate-description.rst b/source/includes/api-details/swift/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..4c16144ce4 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-aggregate-description.rst @@ -0,0 +1,12 @@ +In Swift, you can perform aggregations with these methods: + +- :swift-sdk:`.avg + ` +- :swift-sdk:`.min + ` +- :swift-sdk:`.max + ` +- :swift-sdk:`.count + ` +- :swift-sdk:`.sum + ` diff --git a/source/includes/api-details/swift/crud/read-all-objects-of-type-description.rst b/source/includes/api-details/swift/crud/read-all-objects-of-type-description.rst new file mode 100644 index 0000000000..e0e5d2e60b --- /dev/null +++ b/source/includes/api-details/swift/crud/read-all-objects-of-type-description.rst @@ -0,0 +1,22 @@ +To query for objects of a given type in the database, pass the metatype +instance ``YourClassName.self`` to :swift-sdk:`Realm.objects(_:) +`. +This returns a :swift-sdk:`Results ` object +representing all objects of the given type in the database. + +Read an Object Asynchronously +````````````````````````````` + +When you use an actor-isolated database instance, you can use Swift +concurrency features to asynchronously query objects. + +.. literalinclude:: /examples/generated/code/start/RealmActor.snippet.read-objects.swift + :language: swift + +If you need to manually advance the state of an observed database on the main +thread or an actor-isolated realm, call ``await realm.asyncRefresh()``. +This updates the database and outstanding objects managed by the database to +point to the most recent data and deliver any applicable notifications. + +For more information about working with the SDK using Swift concurrency +features, refer to :ref:`swift-actor-isolated-realm`. diff --git a/source/includes/api-details/swift/crud/read-chain-queries-description.rst b/source/includes/api-details/swift/crud/read-chain-queries-description.rst new file mode 100644 index 0000000000..a506cd6b14 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-chain-queries-description.rst @@ -0,0 +1,2 @@ +To get a result set for tan dogs, and tan dogs whose names start with +'B', you can chain two queries. diff --git a/source/includes/api-details/swift/crud/read-database-objects-procedure.rst b/source/includes/api-details/swift/crud/read-database-objects-procedure.rst new file mode 100644 index 0000000000..23b4ad367d --- /dev/null +++ b/source/includes/api-details/swift/crud/read-database-objects-procedure.rst @@ -0,0 +1,26 @@ +To find objects stored within a database: + +1. Query for objects of a given type in the database. Pass the object type + to the :swift-sdk:`Realm.objects() + ` + method. + +#. Optionally, pass any query conditions to further refine the results: + + - Specify a filter to only return objects that meet the condition. If + you don't specify a filter, the SDK returns all objects of the specified + type. + + - Specify the sort order for the results. + Because the database is unordered, if you don't include a sort order, + the SDK cannot guarantee the query returns objects in any specific order. + +#. Work with the results. Objects may be frozen or live, depending on whether + you queried a frozen or live database, collection, or object. + +Note that any retrieved results don't actually hold matching database objects +in memory. Instead, the database uses **direct references**, or pointers. +Database objects in a results collection reference the matched objects, which +map directly to data in the database file. This also means that you can +traverse your graph of an object's :ref:`relationships ` +directly through the results of a query. diff --git a/source/includes/api-details/swift/crud/read-define-geospatial-shapes-box-description.rst b/source/includes/api-details/swift/crud/read-define-geospatial-shapes-box-description.rst new file mode 100644 index 0000000000..0b69f0455e --- /dev/null +++ b/source/includes/api-details/swift/crud/read-define-geospatial-shapes-box-description.rst @@ -0,0 +1,3 @@ +A :swift-sdk:`GeoBox ` is a +rectangular shape whose bounds are determined by coordinates for a bottom-left +and a top-right corner. diff --git a/source/includes/api-details/swift/crud/read-define-geospatial-shapes-circle-description.rst b/source/includes/api-details/swift/crud/read-define-geospatial-shapes-circle-description.rst new file mode 100644 index 0000000000..afd60eb301 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-define-geospatial-shapes-circle-description.rst @@ -0,0 +1,17 @@ +A :swift-sdk:`GeoCircle ` is a +circular shape whose bounds originate from a central :swift-sdk:`GeoPoint +`, and has a size corresponding to +a radius measured in radians. You can use the SDK's convenience +:swift-sdk:`Distance ` structure to +easily work with radii in different units. + +``Distance`` enables you to specify the radius distance for your geo shapes +in one of four units: + +- ``.degrees`` +- ``.kilometers`` +- ``.miles`` +- ``.radians`` + +You can optionally use the supplied convenience methods to convert a +measurement to a different distance units. diff --git a/source/includes/api-details/swift/crud/read-define-geospatial-shapes-polygon-description.rst b/source/includes/api-details/swift/crud/read-define-geospatial-shapes-polygon-description.rst new file mode 100644 index 0000000000..63ee6d7509 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-define-geospatial-shapes-polygon-description.rst @@ -0,0 +1,11 @@ +A :swift-sdk:`GeoPolygon ` is a +polygon shape whose bounds consist of an outer ring, and 0 or more inner holes +to exclude from the geospatial query. + +A polygon's outer ring must contain at least three segments. The last +and the first :swift-sdk:`GeoPoint ` +must be the same, which indicates a closed polygon. This means that it takes +at least four ``GeoPoint`` values to construct a polygon. + +Inner holes in a ``GeoPolygon`` must be entirely contained within the +outer ring. diff --git a/source/includes/api-details/swift/crud/read-filter-or-query-objects-description.rst b/source/includes/api-details/swift/crud/read-filter-or-query-objects-description.rst new file mode 100644 index 0000000000..b465f3ced6 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-filter-or-query-objects-description.rst @@ -0,0 +1,29 @@ +Swift has its own query APIs that use either the type-safe ``where`` syntax, +or a string ``NSPredicate`` query. For more details about the supported +operators available for Swift queries, refer to :ref:`sdks-filter-data-swift`. + +Type-Safe Queries +````````````````` + +To use the type-safe Swift Query API, call :swift-sdk:`.where +` with a closure that contains a query expression as an +argument. + +This query API provides compile-time type-safe query checking. Prefer using +this API over the older string-based ``NSPredicate`` API. + +.. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.where.swift + :language: swift + +NSPredicate Queries +``````````````````` + +To filter with the older string-based ``NSPredicate`` API, call +:swift-sdk:`Results.filter(_:) +` +with a query predicate. + +Prefer using the type-safe query API unless you are using an SDK version +older than 10.19.0. The string-based ``NSPredicate`` query API does not provide +compile-time checking for valid query syntax, and may crash at runtime with +an invalid ``NSPredicate``. diff --git a/source/includes/api-details/swift/crud/read-find-object-by-primary-key-description.rst b/source/includes/api-details/swift/crud/read-find-object-by-primary-key-description.rst new file mode 100644 index 0000000000..02497efe88 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-find-object-by-primary-key-description.rst @@ -0,0 +1,3 @@ +To find a specific object by primary key, call +:swift-sdk:`Realm.object(ofType:forPrimaryKey:) +`. diff --git a/source/includes/api-details/swift/crud/read-intro-description.rst b/source/includes/api-details/swift/crud/read-intro-description.rst new file mode 100644 index 0000000000..a9b13570a8 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-intro-description.rst @@ -0,0 +1,6 @@ +Query operations return a :swift-sdk:`results collection +`. Results collections may be either live or frozen. + +- **Live results** always contain the latest results of the associated query. +- **Frozen results** represent a snapshot that cannot be modified and doesn't + reflect the latest changes to the database. diff --git a/source/includes/api-details/swift/crud/read-limit-not-supported.rst b/source/includes/api-details/swift/crud/read-limit-not-supported.rst new file mode 100644 index 0000000000..9a7eaa6d7c --- /dev/null +++ b/source/includes/api-details/swift/crud/read-limit-not-supported.rst @@ -0,0 +1,3 @@ +Swift does not provide an API to limit query results. Instead, rely on the +SDK's lazy loading characteristics to implicitly limit the objects in +memory by only accessing the objects you need for an operation. diff --git a/source/includes/api-details/swift/crud/read-query-custom-persistable-property-description.rst b/source/includes/api-details/swift/crud/read-query-custom-persistable-property-description.rst new file mode 100644 index 0000000000..bd7f6a5e61 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-custom-persistable-property-description.rst @@ -0,0 +1,39 @@ +Queries on SDK Objects +`````````````````````` + +When working with projected types, queries operate on the persisted type. +However, you can use the mapped types interchangeably with the persisted +types in arguments in most cases. The exception is queries on embedded +objects. + +.. tip:: + + Projected types support :ref:`sorting and aggregates ` + where the persisted type supports them. + +.. literalinclude:: /examples/generated/code/start/TypeProjection.snippet.query-objects-with-type-projection.swift + :language: swift + +Queries on Embedded Objects +``````````````````````````` + +You can query embedded types on the supported property types within the +object using memberwise equality. + +Object link properties support equality comparisons, but do not support +memberwise comparisons. You can query embedded objects for memberwise +equality on all primitive types. You cannot perform memberwise comparison +on objects and collections. + +Dynamic APIs +```````````` + +Because the schema has no concept of custom type mappings, reading data via +any of the dynamic APIs gives the underlying persisted type. The SDK does +support writing mapped types via a dynamic API, and converts the projected +type to the persisted type. + +The most common use of the dynamic APIs is migration. You can write projected +types during migration, and the SDK converts the projected type to the persisted +type. However, reading data during a migration gives the underlying persisted +type. diff --git a/source/includes/api-details/swift/crud/read-query-dictionary-properties-description.rst b/source/includes/api-details/swift/crud/read-query-dictionary-properties-description.rst new file mode 100644 index 0000000000..f647c5b259 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-dictionary-properties-description.rst @@ -0,0 +1,10 @@ +You can iterate and check the values of a realm :swift-sdk:`map ` +as you would a standard :apple:`Dictionary `. + +.. tip:: Map may contain keys whose values are nil + + An SDK map may contain keys with ``nil`` values. If you delete an object + that is used as a map value, the value is set to ``nil`` but the key + remains unless you explicitly delete it. If your app deletes map values + without also explicitly cleaning up the keys, you may need to perform + optional unwrapping when you read map values. diff --git a/source/includes/api-details/swift/crud/read-query-geospatial-data-description.rst b/source/includes/api-details/swift/crud/read-query-geospatial-data-description.rst new file mode 100644 index 0000000000..282d030036 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-geospatial-data-description.rst @@ -0,0 +1,10 @@ +The SDK provides two specialized non-persistable data types to define shapes: + +- :swift-sdk:`GeoPoint `: A + struct that represents the coordinates of a point formed by a pair of + doubles consisting of these values: + + - Latitude: ranges between -90 and 90 degrees, inclusive. + - Longitude: ranges between -180 and 180 degrees, inclusive. +- :swift-sdk:`Distance `: A helper + struct to represent and convert a distance. diff --git a/source/includes/api-details/swift/crud/read-query-inverse-relationship-description.rst b/source/includes/api-details/swift/crud/read-query-inverse-relationship-description.rst new file mode 100644 index 0000000000..280f80ebc0 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-inverse-relationship-description.rst @@ -0,0 +1,6 @@ +You can query :swift-sdk:`LinkingObjects `, +an auto-updating container type, to access zero or more objects that are +linked to its owning model object through a property relationship. You can +query ``LinkingObjects`` with the same APIs and predicates as +:swift-sdk:`List\ ` and +:swift-sdk:`Results\ `. diff --git a/source/includes/api-details/swift/crud/read-query-list-properties-description.rst b/source/includes/api-details/swift/crud/read-query-list-properties-description.rst new file mode 100644 index 0000000000..c0c605383b --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-list-properties-description.rst @@ -0,0 +1,12 @@ +You can query a :swift-sdk:`List ` with the same predicates +as a :swift-sdk:`Results ` collection. Lists implement +the :swift-sdk:`RealmCollection ` protocol, +which provides access to common properties and operators such as: + +- ``.count`` +- ``.first`` and ``.last`` +- ``.where`` query syntax +- ``.sorted(by:)`` and ``.distinct(by:)`` + +Unlike Swift native collections, ``List`` is a reference type. A ``List`` is +only immutable if the database it originates from is opened as read-only. diff --git a/source/includes/api-details/swift/crud/read-query-mixed-properties-description.rst b/source/includes/api-details/swift/crud/read-query-mixed-properties-description.rst new file mode 100644 index 0000000000..f92d27fe49 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-mixed-properties-description.rst @@ -0,0 +1,21 @@ +When you read an :swift-sdk:`AnyRealmValue ` +property, check the value's type before doing anything with it. The SDK +provides an :swift-sdk:`AnyRealmValue enum ` that +iterates through all of the types the ``AnyRealmValue`` can store. + +You can :ref:`compare ` these mixed +value types: + +- Numeric: int, bool, float, double, decimal +- Byte-based: string, binary +- Time-based: timestamp, objectId + +When using the ``AnyRealmValue`` mixed data type, keep these things in mind: + +- ``equals`` queries match on value and type +- ``not equals`` queries match objects with either different values or + different types +- The SDK converts comparable numeric properties where possible. For example, + in a mixed type field, 1 matches all of 1.0, 1, and true. +- String properties do not match numeric queries. For example, in a mixed + type field, 1 does not match "1". "1" does not match 1, 1.0, or true. diff --git a/source/includes/api-details/swift/crud/read-query-projections-description.rst b/source/includes/api-details/swift/crud/read-query-projections-description.rst new file mode 100644 index 0000000000..e966217a67 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-projections-description.rst @@ -0,0 +1,8 @@ +To query for class projections, pass the metatype instance +``YourProjectionName.self`` to :swift-sdk:`Realm.objects(_:) +`. +This returns a :swift-sdk:`Results ` object +representing all of the class projection objects in the database. + +.. literalinclude:: /examples/generated/code/start/ClassProjection.snippet.retrieve-data-through-class-projection.swift + :language: swift diff --git a/source/includes/api-details/swift/crud/read-query-set-properties-description.rst b/source/includes/api-details/swift/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..c0b61199b7 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-set-properties-description.rst @@ -0,0 +1,4 @@ +You can query a :swift-sdk:`MutableSet ` to check if +it contains an element. If you are working with multiple sets, you can +check for the intersection of two sets, or check whether one set is a subset +of the other set. diff --git a/source/includes/api-details/swift/crud/read-query-with-geospatial-shapes-description.rst b/source/includes/api-details/swift/crud/read-query-with-geospatial-shapes-description.rst new file mode 100644 index 0000000000..96ed1d3310 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-query-with-geospatial-shapes-description.rst @@ -0,0 +1,12 @@ +You can query geospatial data in two ways: + +- Using the :swift-sdk:`.geoWithin() + ` + operator with the type-safe :ref:`Swift Query API ` +- Using a :swift-sdk:`.filter() + ` + with an :ref:`NSPredicate query ` that uses + ``geoWithin``. + +The examples below show the results of queries using these two ``Company`` +objects. diff --git a/source/includes/api-details/swift/crud/read-sdk-results-collections-description.rst b/source/includes/api-details/swift/crud/read-sdk-results-collections-description.rst new file mode 100644 index 0000000000..4a64ba24d9 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-sdk-results-collections-description.rst @@ -0,0 +1,26 @@ +The SDK's :swift-sdk:`Results ` collection is +a class representing objects retrieved from queries. A ``Results`` collection +represents the lazily-evaluated results of a query operation, and has these +characteristics: + +- Results are immutable: you cannot manually add or remove elements to or from + the results collection. +- Results have an associated query that determines their contents. +- Results are **live** or **frozen** based on the query source. If they derive + from live objects, the results automatically update when the database + contents on the thread change. If they derive from frozen objects, they + represent only a snapshot and do not automatically update. +- You cannot manually initialize an empty ``Results`` set. Results can only + be initialized as the result of a query. + +In Swift, the SDK also provides :swift-sdk:`SectionedResults +`, a type-safe collection which holds +``ResultsSection`` as its elements. Each :swift-sdk:`ResultSection +` is a collection that contains only +objects that belong to a given section key. + +For example, an app that includes a contact list might use SectionedResults +to display a list of contacts divided into sections, where each section +contains all the contacts whose first name starts with the given letter. +The ``ResultsSection`` whose key is "L" would contain "Larry", "Liam", +and "Lisa". diff --git a/source/includes/api-details/swift/crud/read-section-query-results-description.rst b/source/includes/api-details/swift/crud/read-section-query-results-description.rst new file mode 100644 index 0000000000..a2a7a8b95f --- /dev/null +++ b/source/includes/api-details/swift/crud/read-section-query-results-description.rst @@ -0,0 +1,29 @@ +For example, you might add a computed variable to your object to get the +first letter of the ``name`` property: + +.. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.sectioned-result-variable.swift + :language: swift + +Then, you can create a :swift-sdk:`SectionedResults ` +type-safe collection for that object, and use it to retrieve objects sectioned +by that computed variable: + +.. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.get-sectioned-results.swift + :language: swift + +You can get a count of the sections, get a list of keys, or access an individual +:swift-sdk:`ResultSection ` by index: + +.. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.section-query-results.swift + :language: swift + +You can also section using a callback. This enables you to section a +collection of primitives, or have more control over how the section key is +generated. + +.. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.section-query-results-callback.swift + :language: swift + +You can :ref:`observe ` ``SectionedResults`` and +``ResultsSection`` instances, and both conform to +:swift-sdk:`ThreadConfined `. diff --git a/source/includes/api-details/swift/crud/read-sort-description.rst b/source/includes/api-details/swift/crud/read-sort-description.rst new file mode 100644 index 0000000000..d9192c0304 --- /dev/null +++ b/source/includes/api-details/swift/crud/read-sort-description.rst @@ -0,0 +1,3 @@ +You can sort using the type-safe keyPath by calling +:swift-sdk:`Results.sorted(by: ) ` with the +keyPath name and optional sort order. diff --git a/source/includes/api-details/typescript/crud/read-aggregate-description.rst b/source/includes/api-details/typescript/crud/read-aggregate-description.rst new file mode 100644 index 0000000000..4d51396248 --- /dev/null +++ b/source/includes/api-details/typescript/crud/read-aggregate-description.rst @@ -0,0 +1,4 @@ +In TypeScript, you perform aggregations through the :js-sdk:`filtered() +` method. In the ``filtered()`` method's +argument, use :ref:`Realm Query Language aggregate operators +` to aggregate data. diff --git a/source/includes/api-details/typescript/crud/read-filter-full-text-search-property-description.rst b/source/includes/api-details/typescript/crud/read-filter-full-text-search-property-description.rst new file mode 100644 index 0000000000..4bcd446879 --- /dev/null +++ b/source/includes/api-details/typescript/crud/read-filter-full-text-search-property-description.rst @@ -0,0 +1,8 @@ +To query an FTS indexed property, use the ``TEXT`` predicate in your +:js-sdk:`filtered ` query. + +In the following example, we query on the ``Book.name`` field using the +following ``Book`` object model. + +.. literalinclude:: /examples/generated/node/v12/full-text-search.test.snippet.node-fts-annotation.ts + :language: typescript diff --git a/source/includes/api-details/typescript/crud/read-query-set-properties-description.rst b/source/includes/api-details/typescript/crud/read-query-set-properties-description.rst new file mode 100644 index 0000000000..091f06fbfd --- /dev/null +++ b/source/includes/api-details/typescript/crud/read-query-set-properties-description.rst @@ -0,0 +1,20 @@ +Sets allow you to perform math operations such as finding the union, +intersection, or difference between two sets. To learn more about performing +these operations, see the MDN docs for :mdn:`Implementing basic set operations +`. + +To determine if a set contains a particular value, pass the value to the +``.has()`` method. The ``set.has()`` method will return true if the +set contains the value specified. + +To discover how many items are in a set, you can check the set's ``size`` +property. + +To traverse a set, use the ``.forEach()`` method or alternative +:mdn:`iteration method +`. + +The order of the **Realm.Set** may be different from the order that the items +were added. + +You can track the set order by updating an array when a new value is added. diff --git a/source/includes/sdk-examples/crud/read-access-results.rst b/source/includes/sdk-examples/crud/read-access-results.rst new file mode 100644 index 0000000000..a334229fcd --- /dev/null +++ b/source/includes/sdk-examples/crud/read-access-results.rst @@ -0,0 +1,70 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.check-size-and-access-results.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.iteration.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-aggregate.rst b/source/includes/sdk-examples/crud/read-aggregate.rst new file mode 100644 index 0000000000..736329d5f2 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-aggregate.rst @@ -0,0 +1,66 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.aggregate.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.aggregate-operators.java + :language: java + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.aggregate-operators.kt + :language: kotlin + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.aggregate-results.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.aggregate.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.tsq-aggregate.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-all-objects-of-type.rst b/source/includes/sdk-examples/crud/read-all-objects-of-type.rst new file mode 100644 index 0000000000..ad805a598b --- /dev/null +++ b/source/includes/sdk-examples/crud/read-all-objects-of-type.rst @@ -0,0 +1,63 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.read-objects-from-realm.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.read_all.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.query-all-objects.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.get-all-objects.java + :language: java + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.get-all-objects.kt + :language: kotlin + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-data-query-an-object-type.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-by-object-type.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.objects.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.objects.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-chain-queries.rst b/source/includes/sdk-examples/crud/read-chain-queries.rst new file mode 100644 index 0000000000..e264ec07ab --- /dev/null +++ b/source/includes/sdk-examples/crud/read-chain-queries.rst @@ -0,0 +1,70 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.kt + :language: kotlin + :copyable: false + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.chain-query.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.tsq-chain-query.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-define-geospatial-shapes-box.rst b/source/includes/sdk-examples/crud/read-define-geospatial-shapes-box.rst new file mode 100644 index 0000000000..a03cb56407 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-define-geospatial-shapes-box.rst @@ -0,0 +1,66 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Geospatial.snippet.geobox.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/geospatial_data_test.snippet.geobox.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geobox.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/Geospatial.snippet.geobox.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geobox.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geobox.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-define-geospatial-shapes-circle.rst b/source/includes/sdk-examples/crud/read-define-geospatial-shapes-circle.rst new file mode 100644 index 0000000000..226a0eb966 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-define-geospatial-shapes-circle.rst @@ -0,0 +1,66 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Geospatial.snippet.geocircle.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/geospatial_data_test.snippet.geocircle.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geocircle.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/Geospatial.snippet.geocircle.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geocircle.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geocircle.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-define-geospatial-shapes-polygon.rst b/source/includes/sdk-examples/crud/read-define-geospatial-shapes-polygon.rst new file mode 100644 index 0000000000..a0c305a549 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-define-geospatial-shapes-polygon.rst @@ -0,0 +1,67 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Geospatial.snippet.geopolygon.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geopolygon.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/Geospatial.snippet.geopolygon.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geopolygon.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geopolygon.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-filter-by-remapped-property-name.rst b/source/includes/sdk-examples/crud/read-filter-by-remapped-property-name.rst new file mode 100644 index 0000000000..bb9071d15c --- /dev/null +++ b/source/includes/sdk-examples/crud/read-filter-by-remapped-property-name.rst @@ -0,0 +1,71 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-remapped-property.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-filter-full-text-search-property.rst b/source/includes/sdk-examples/crud/read-filter-full-text-search-property.rst new file mode 100644 index 0000000000..9b9bf86786 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-filter-full-text-search-property.rst @@ -0,0 +1,69 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Indexing.snippet.rql-query-fts.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/full_text_search_test.snippet.flutter-fts-query.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-fts-property.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/full-text-search.test.snippet.node-fts-query.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-filter-or-query-objects.rst b/source/includes/sdk-examples/crud/read-filter-or-query-objects.rst new file mode 100644 index 0000000000..7b3e62bb55 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-filter-or-query-objects.rst @@ -0,0 +1,63 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.filter-using-type-safe-query.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.rql.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.filter-iterable.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.realm-query-language.java + :language: java + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.realm-query-language.kt + :language: kotlin + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-filter-queries.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-by-property.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.filter.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.filter.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-find-object-by-primary-key.rst b/source/includes/sdk-examples/crud/read-find-object-by-primary-key.rst new file mode 100644 index 0000000000..56b501f4cc --- /dev/null +++ b/source/includes/sdk-examples/crud/read-find-object-by-primary-key.rst @@ -0,0 +1,64 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.get_by_id.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.query-object-by-pk.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.find-an-object-by-primary-key.java + :language: java + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.find-an-object-by-primary-key.kt + :language: kotlin + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-data-object-for-primary-key.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.find-by-primary-key.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.find-a-specific-object-by-primary-key.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.find-a-specific-object-by-primary-key.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-limit.rst b/source/includes/sdk-examples/crud/read-limit.rst new file mode 100644 index 0000000000..3780b9f360 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-limit.rst @@ -0,0 +1,69 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.limit.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.sort-results.java + :language: java + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.sort-results.kt + :language: kotlin + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.kt + :language: kotlin + :copyable: false + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-query-dictionary-properties.rst b/source/includes/sdk-examples/crud/read-query-dictionary-properties.rst new file mode 100644 index 0000000000..281043b92c --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-dictionary-properties.rst @@ -0,0 +1,67 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.read-map-value.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/data_types_test.snippet.map-work-with.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/data-types.snippet.query-a-dictionary.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.read-realm-dictionary.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.map.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-query-inverse-relationship.rst b/source/includes/sdk-examples/crud/read-query-inverse-relationship.rst new file mode 100644 index 0000000000..ea61a2afe1 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-inverse-relationship.rst @@ -0,0 +1,66 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Relationships.snippet.inverse-query.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/backlinks_test.snippet.filter-backlinks-rql.dart + :language: dart + + - id: java + content: | + + .. include:: /examples/generated/java/sync/RealmQueryTest.snippet.query-an-inverse-relationship.java.rst + + - id: java-kotlin + content: | + + .. include:: /examples/generated/java/sync/RealmQueryTest.snippet.query-an-inverse-relationship.kt.rst + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/relationships.test.snippet.obtain-inverse-relationship-dynamically.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.persisted-name-inverse.kt + :language: kotlin + :emphasize-lines: 1 + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-inverse-persisted-name.kt + :language: kotlin + :emphasize-lines: 4 + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.query-an-inverse-relationship.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.query-an-inverse-relationship.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/relationships.test.snippet.obtain-inverse-relationship-dynamically.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-query-list-properties.rst b/source/includes/sdk-examples/crud/read-query-list-properties.rst new file mode 100644 index 0000000000..d8f056609d --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-list-properties.rst @@ -0,0 +1,70 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/data_types_test.snippet.realmlist-use.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.read-realm-list.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-query-mixed-properties.rst b/source/includes/sdk-examples/crud/read-query-mixed-properties.rst new file mode 100644 index 0000000000..6f7317e2f8 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-mixed-properties.rst @@ -0,0 +1,69 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/data-types.snippet.query-objects-with-mixed-values.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.get-realmany-property.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.mixed-data-type.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-query-set-properties.rst b/source/includes/sdk-examples/crud/read-query-set-properties.rst new file mode 100644 index 0000000000..abc9768915 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-set-properties.rst @@ -0,0 +1,67 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/crud.snippet.read-set.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cs + :language: csharp + :copyable: false + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/data_types_test.snippet.realm-set-examples.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/data-types.snippet.make-array-with-insertion-order-from-set.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.read-realm-set.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.set-collections.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-query-to-many-relationship.rst b/source/includes/sdk-examples/crud/read-query-to-many-relationship.rst new file mode 100644 index 0000000000..fc55b71d36 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-to-many-relationship.rst @@ -0,0 +1,69 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Relationships.snippet.one-to-many-query.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/data_types_test.snippet.realmlist-use.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/RealmQueryTest.snippet.query-a-relationship.java + :language: java + :emphasize-lines: 16 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/RealmQueryTest.snippet.query-a-relationship.kt + :language: kotlin + :emphasize-lines: 15 + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-to-many-relationship.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-query-to-one-relationship.rst b/source/includes/sdk-examples/crud/read-query-to-one-relationship.rst new file mode 100644 index 0000000000..d9314ed4e8 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-to-one-relationship.rst @@ -0,0 +1,70 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Relationships.snippet.one-to-one-query.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/RealmQueryTest.snippet.query-a-relationship.java + :language: java + :emphasize-lines: 16 + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/RealmQueryTest.snippet.query-a-relationship.kt + :language: kotlin + :emphasize-lines: 15 + + - id: javascript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.js + :language: javascript + :copyable: false + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-to-one-relationship.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.swift + :language: swift + :copyable: false + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-box.rst b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-box.rst new file mode 100644 index 0000000000..46ce940f38 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-box.rst @@ -0,0 +1,73 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Geospatial.snippet.geobox-query.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/geospatial_data_test.snippet.geobox-query.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geobox-query.js + :language: javascript + + - id: kotlin + content: | + + .. io-code-block:: + + .. input:: /examples/generated/kotlin/Geospatial.snippet.geobox-query.kt + :language: kotlin + + .. output:: + + Companies in large box: 1 + Companies in small box: 2 + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geobox-query.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geobox-query.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-circle.rst b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-circle.rst new file mode 100644 index 0000000000..4d2bd7703b --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-circle.rst @@ -0,0 +1,73 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Geospatial.snippet.geocircle-query.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/geospatial_data_test.snippet.geocircle-query.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geocircle-query.js + :language: javascript + + - id: kotlin + content: | + + .. io-code-block:: + + .. input:: /examples/generated/kotlin/Geospatial.snippet.geocircle-query.kt + :language: kotlin + + .. output:: + + Companies in large circle: 1 + Companies in small circle: 0 + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geocircle-query.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geocircle-query.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-polygon.rst b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-polygon.rst new file mode 100644 index 0000000000..0f75a8c4a1 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes-polygon.rst @@ -0,0 +1,74 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Geospatial.snippet.geopolygon-query.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.dart + :language: dart + :copyable: false + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geopolygon-query.js + :language: javascript + + - id: kotlin + content: | + + .. io-code-block:: + + .. input:: /examples/generated/kotlin/Geospatial.snippet.geopolygon-query.kt + :language: kotlin + + .. output:: + + Companies in basic polygon: 2 + Companies in polygon with holes: 1 + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geopolygon-query.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.geopolygon-query.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes.rst b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes.rst new file mode 100644 index 0000000000..f6259d17d3 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-query-with-geospatial-shapes.rst @@ -0,0 +1,66 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.cpp + :language: cpp + :copyable: false + + - id: csharp + content: | + + .. literalinclude:: /examples/generated/dotnet/Geospatial.snippet.geopoint.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/geospatial_data_test.snippet.write-geospatial-object.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api.java + :language: java + :copyable: false + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt + :language: kotlin + :copyable: false + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.write-geospatial-object.js + :language: javascript + + - id: kotlin + content: | + + .. literalinclude:: /examples/generated/kotlin/Geospatial.snippet.create-geopoint.kt + :language: kotlin + + - id: objectivec + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.m + :language: objectivec + :copyable: false + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/Geospatial.snippet.companies.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/generated/node/v12/geospatial.test.snippet.write-geospatial-object.ts + :language: typescript diff --git a/source/includes/sdk-examples/crud/read-sort.rst b/source/includes/sdk-examples/crud/read-sort.rst new file mode 100644 index 0000000000..130876f6e8 --- /dev/null +++ b/source/includes/sdk-examples/crud/read-sort.rst @@ -0,0 +1,65 @@ +.. tabs-drivers:: + + tabs: + - id: cpp-sdk + content: | + + .. literalinclude:: /examples/generated/cpp/filter-data.snippet.sort-list-by-multiple-properties.cpp + :language: cpp + + - id: csharp + content: | + + .. literalinclude:: /examples/CRUD/Sort.cs + :language: csharp + + - id: dart + content: | + + .. literalinclude:: /examples/generated/flutter/read_write_data_test.snippet.sort.dart + :language: dart + + - id: java + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.sort-results.java + :language: java + + - id: java-kotlin + content: | + + .. literalinclude:: /examples/generated/java/sync/ReadsTest.snippet.sort-results.kt + :language: kotlin + + - id: javascript + content: | + + .. literalinclude:: /examples/generated/node/read-and-write-data.snippet.read-and-write-sorted-queries.js + :language: javascript + :emphasize-lines: 4, 6, 8, 13 + + - id: kotlin + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.kt + :language: kotlin + :copyable: false + + - id: objectivec + content: | + + .. literalinclude:: /examples/generated/code/start/ReadWriteData.snippet.sort.m + :language: objectivec + + - id: swift + content: | + + .. literalinclude:: /examples/generated/code/start/ReadRealmObjects.snippet.sort-type-safe.swift + :language: swift + + - id: typescript + content: | + + .. literalinclude:: /examples/MissingPlaceholders/example.ts + :language: typescript + :copyable: false diff --git a/source/includes/sdk-examples/query/rql-example-data-model.rst b/source/includes/sdk-examples/query/rql-example-data-model.rst index 8cec6893b2..12227fc183 100644 --- a/source/includes/sdk-examples/query/rql-example-data-model.rst +++ b/source/includes/sdk-examples/query/rql-example-data-model.rst @@ -1,7 +1,7 @@ .. tabs-drivers:: tabs: - - id: cpp + - id: cpp-sdk content: | .. literalinclude:: /examples/generated/cpp/filter-data.snippet.models.cpp diff --git a/source/index.txt b/source/index.txt index fb684ed1cf..30ff575a30 100644 --- a/source/index.txt +++ b/source/index.txt @@ -147,7 +147,7 @@ other clients. :ref:`Create `, :ref:`read `, :ref:`update `, and :ref:`delete ` objects from the device database. Filter data using the - :ref:`query engines ` provided by the SDK. + :ref:`query engines ` provided by the SDK. .. step:: React to Changes diff --git a/source/platforms/apple/use-sdk-with-actors.txt b/source/platforms/apple/use-sdk-with-actors.txt index f5ebc3db98..b9bb55f90b 100644 --- a/source/platforms/apple/use-sdk-with-actors.txt +++ b/source/platforms/apple/use-sdk-with-actors.txt @@ -208,7 +208,7 @@ object local to that actor. If you may need to share the same database object across actors more than once, you may prefer to share the :ref:`primary key ` - and :ref:`query for it ` on + and :ref:`query for it ` on the actor where you want to use it. Refer to the "Pass a Primary Key and Query for the Object on Another Actor" section on this page for an example. @@ -240,7 +240,7 @@ Pass a Primary Key and Query for the Object on Another Actor If you want to use a database object on another actor, you can share the :ref:`primary key ` and -:ref:`query for it ` on the actor +:ref:`query for it ` on the actor where you want to use it. .. literalinclude:: /examples/generated/code/start/RealmActor.snippet.query-for-data-on-another-actor.swift diff --git a/source/sdk/crud.txt b/source/sdk/crud.txt index 1dd90517b4..18ef505e6c 100644 --- a/source/sdk/crud.txt +++ b/source/sdk/crud.txt @@ -19,5 +19,5 @@ manage objects across threads, and use the Atlas Device SDK query engines: - :ref:`sdks-crud-read` - :ref:`sdks-crud-update` - :ref:`sdks-crud-delete` -- :ref:`sdks-query-engines` +- :ref:`realm-query-language` - :ref:`sdks-threading` diff --git a/source/sdk/crud/query-engines.txt b/source/sdk/crud/query-engines.txt index 4339163c25..e74855ff7f 100644 --- a/source/sdk/crud/query-engines.txt +++ b/source/sdk/crud/query-engines.txt @@ -14,6 +14,6 @@ The following pages contain information about how to use the Atlas Device SDK query engines: - :ref:`realm-query-language` -- :ref:`java-filter-data` -- :ref:`dotnet-linq` +- :ref:`sdks-java-filter-data` +- :ref:`sdks-dotnet-linq` - :ref:`sdks-filter-data-swift` diff --git a/source/sdk/crud/query-engines/filter-data-java-sdk.txt b/source/sdk/crud/query-engines/filter-data-java-sdk.txt index 12a2f46f34..6f58517cd3 100644 --- a/source/sdk/crud/query-engines/filter-data-java-sdk.txt +++ b/source/sdk/crud/query-engines/filter-data-java-sdk.txt @@ -1,8 +1,20 @@ -.. _java-filter-data: +.. _sdks-java-filter-data: -====================== -Filter Data - Java SDK -====================== +============================================ +Filter Data with Fluent Interface - Java SDK +============================================ + +.. meta:: + :description: Atlas Device SDK for Java provides a Fluent Interface query engine for an idiomatic query experience in Java and Kotlin. + :keywords: Realm, Java SDK, code example + +.. facet:: + :name: genre + :values: reference + +.. facet:: + :name: programming_language + :values: java, kotlin .. contents:: On this page :local: @@ -10,4 +22,582 @@ Filter Data - Java SDK :depth: 2 :class: singlecol -Placeholder for filtering data in the Java SDK using the Fluent interface. \ No newline at end of file +.. tabs-selector:: drivers + +Atlas Device SDK for Java uses a :wikipedia:`Fluent interface ` +to construct multi-clause queries that are passed to the query engine. + +See :java-sdk:`RealmQuery API ` for a complete list +of available methods. + +There are several types of operators available to filter an SDK collection. +Filters work by **evaluating** an operator expression for every object in the +collection being filtered. If the expression resolves to ``true``, the SDK +includes the object in the results collection. + +An **expression** consists of one of the following: + +- The name of a property of the object currently being evaluated. +- An operator and up to two argument expression(s). +- A literal string, number, or date. + +Fluent Interface Expressions +---------------------------- + +About the Examples In This Section +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The examples in this section use a simple data set for a +task list app. The two SDK object types are ``Project`` +and ``Task``. A ``Task`` has a name, assignee's name, and +completed flag. There is also an arbitrary number for +priority (higher is more important) and a count of +minutes spent working on it. A ``Project`` has zero or more +``Tasks``. + +See the schema for these two classes, ``Project`` and +``Task``, below: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/sync/ProjectTask.snippet.projecttask.java + :language: java + :caption: ProjectTask.java + :copyable: false + + .. literalinclude:: /examples/generated/java/sync/Project.snippet.project.java + :language: java + :caption: Project.java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/sync/ProjectTask.snippet.projecttask.kt + :language: kotlin + :caption: ProjectTask.kt + :copyable: false + + .. literalinclude:: /examples/generated/java/sync/Project.snippet.project.kt + :language: kotlin + :caption: Project.kt + :copyable: false + +Comparison Operators +~~~~~~~~~~~~~~~~~~~~ + +The most straightforward operation in a search is to compare +values. + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Operator + - Description + + * - ``between`` + - Evaluates to ``true`` if the left-hand numerical or date expression is between or equal to the right-hand range. For dates, this evaluates to ``true`` if the left-hand date is within the right-hand date range. + + * - | ``equalTo`` + - Evaluates to ``true`` if the left-hand expression is equal to the right-hand expression. + + * - | ``greaterThan`` + - Evaluates to ``true`` if the left-hand numerical or date expression is greater than the right-hand numerical or date expression. For dates, this evaluates to ``true`` if the left-hand date is later than the right-hand date. + + * - | ``greaterThanOrEqualTo`` + - Evaluates to ``true`` if the left-hand numerical or date expression is greater than or equal to the right-hand numerical or date expression. For dates, this evaluates to ``true`` if the left-hand date is later than or the same as the right-hand date. + + * - ``in`` + - Evaluates to ``true`` if the left-hand expression is in the right-hand list. + + * - | ``lessThan`` + - Evaluates to ``true`` if the left-hand numerical or date expression is less than the right-hand numerical or date expression. For dates, this evaluates to ``true`` if the left-hand date is earlier than the right-hand date. + + * - | ``lessThanOrEqualTo`` + - Evaluates to ``true`` if the left-hand numeric expression is less than or equal to the right-hand numeric expression. For dates, this evaluates to ``true`` if the left-hand date is earlier than or the same as the right-hand date. + + * - | ``notEqualTo`` + - Evaluates to ``true`` if the left-hand expression is not equal to the right-hand expression. + +.. example:: + + The following example uses the query engine's + comparison operators to: + + - Find high priority tasks by comparing the value of the ``priority`` property value with a threshold number, above which priority can be considered high. + - Find just-started or short-running tasks by seeing if the ``progressMinutes`` property falls within a certain range. + - Find unassigned tasks by finding tasks where the ``assignee`` property is equal to ``null``. + - Find tasks assigned to specific teammates Ali or Jamie by seeing if the ``assignee`` property is in a list of names. + + .. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.comparison-operators.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.comparison-operators.kt + :language: kotlin + :copyable: false + +Logical Operators +~~~~~~~~~~~~~~~~~ + +You can make compound predicates using logical operators. + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Operator + - Description + + * - | ``and`` + - Evaluates to ``true`` if both left-hand and right-hand expressions are ``true``. + + * - | ``not`` + - Negates the result of the given expression. + + * - | ``or`` + - Evaluates to ``true`` if either expression returns ``true``. + +.. example:: + + We can use the query language's logical operators to find + all of Ali's completed tasks. That is, we find all tasks + where the ``assignee`` property value is equal to 'Ali' AND + the ``isComplete`` property value is ``true``: + + .. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.logical-operators.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.logical-operators.kt + :language: kotlin + :copyable: false + +.. _java-string-operators: + +String Operators +~~~~~~~~~~~~~~~~ + +You can compare string values using these string operators. +Regex-like wildcards allow more flexibility in search. + +.. list-table:: + :header-rows: 1 + :widths: 40 60 + + * - Operator + - Description + + * - | ``beginsWith`` + - Evaluates to ``true`` if the left-hand string expression begins with the right-hand string expression. This is similar to ``contains``, but only matches if the left-hand string expression is found at the beginning of the right-hand string expression. + + * - ``contains`` + - Evaluates to ``true`` if the left-hand string expression is found anywhere in the right-hand string expression. + + * - | ``endsWith`` + - Evaluates to ``true`` if the left-hand string expression ends with the right-hand string expression. This is similar to ``contains``, but only matches if the left-hand string expression is found at the very end of the right-hand string expression. + + * - | ``like`` + - Evaluates to ``true`` if the left-hand string expression + matches the right-hand string wildcard string + expression. A wildcard string expression is a string + that uses normal characters with two special wildcard + characters: + + - The ``*`` wildcard matches zero or more of any character + - The ``?`` wildcard matches any character. + + For example, the wildcard string "d?g" matches "dog", + "dig", and "dug", but not "ding", "dg", or "a dog". + + * - | ``equalTo`` + - Evaluates to ``true`` if the left-hand string is lexicographically equal to the right-hand string. + +.. example:: + + We use the query engine's string operators to find + projects with a name starting with the letter 'e' and + projects with names that contain 'ie': + + .. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.string-operators.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.string-operators.kt + :language: kotlin + :copyable: false + +.. note:: Case-insensitive Character Limitations + + Case-insensitive string operators only support the + ``Latin Basic``, ``Latin Supplement``, ``Latin Extended A``, and + ``Latin Extended B (UTF-8 range 0–591)`` character sets. Setting + the case insensitive flag in queries when using ``equalTo``, + ``notEqualTo``, ``contains``, ``endsWith``, ``beginsWith``, or + ``like`` only works on English locale characters. + +Aggregate Operators +~~~~~~~~~~~~~~~~~~~ + +You can apply an aggregate operator to a collection property of an SDK object. +Aggregate operators traverse a collection and reduce it to a single value. + +.. list-table:: + :header-rows: 1 + :widths: 40 60 + + * - Operator + - Description + + * - | ``average`` + - Evaluates to the average value of a given numerical property across a collection. + + * - | ``count`` + - Evaluates to the number of objects in the given collection. + + * - | ``max`` + - Evaluates to the highest value of a given numerical property across a collection. + + * - | ``min`` + - Evaluates to the lowest value of a given numerical property across a collection. + + * - | ``sum`` + - Evaluates to the sum of a given numerical property across a collection. + +.. example:: + + We create a couple of filters to show different facets of + the data: + + - Projects with average tasks priority above 5. + - Long running projects. + + .. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.aggregate-operators.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/sync/QueryEngineTest.snippet.aggregate-operators.kt + :language: kotlin + :copyable: false + +Filter, Sort, Limit, Unique, and Chain Queries +---------------------------------------------- + +About the Examples in This Section +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The examples in this section use two Realm object types: ``Teacher`` +and ``Student``. + +See the schema for these two classes below: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/Teacher.snippet.complete.java + :language: java + :caption: Teacher.java + :copyable: false + + .. literalinclude:: /examples/generated/java/local/Student.snippet.complete.java + :language: java + :caption: Student.java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/TeacherKt.snippet.complete.kt + :language: kotlin + :caption: Teacher.kt + :copyable: false + + .. literalinclude:: /examples/generated/java/local/StudentKt.snippet.complete.kt + :language: kotlin + :caption: Student.kt + :copyable: false + +.. _java-client-filters: + +Filters +~~~~~~~ + +You can build filters using the operator methods of the +:wikipedia:`fluent interface ` exposed by the +:java-sdk:`RealmQuery ` class: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.filters.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.filters.kt + :language: kotlin + :copyable: false + +This gives you a new instance of the class :java-sdk:`RealmResults `, +containing teachers with the name "Ms. Langtree" or "Mrs. Jacobs". + +``RealmQuery`` includes several methods that can execute queries: + +- :java-sdk:`findAll() ` blocks until + it finds all objects that meet the query conditions + +- :java-sdk:`findAllAsync() ` + returns immediately and finds all objects that meet the query + conditions asynchronously on a background thread + +- :java-sdk:`findFirst() ` blocks + until it finds the first object that meets the query conditions + +- :java-sdk:`findFirstAsync() ` + returns immediately and finds the first object that meets the query + conditions asynchronously on a background thread + +Queries return a list of references to the matching SDK objects using the +:java-sdk:`RealmResults ` type. + +.. _java-link-queries: + +Link Queries +````````````` + +When referring to an object property, you can use **dot notation** to refer +to child properties of that object. You can refer to the properties of +:ref:`embedded objects ` and :ref:`relationships +` with dot notation. + +For example, consider a query for all teachers with a student named +"Wirt" or "Greg": + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.link-queries.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.link-queries.kt + :language: kotlin + :copyable: false + +You can even use dot notation to query inverse relationships: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.link-queries-inverse.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.link-queries-inverse.kt + :language: kotlin + :copyable: false + +.. _java-sort-results: + +Sort Results +~~~~~~~~~~~~ + +.. important:: + + Realm applies the ``distinct()``, ``sort()`` and + ``limit()`` methods in the order you specify. Depending on the + data set this can alter the query result. Generally, you should + apply ``limit()`` last to avoid unintended result sets. + +You can define the order of query results using the +:java-sdk:`sort() ` +method: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.sort.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.sort.kt + :language: kotlin + :copyable: false + +Sorts organize results in ascending order by default. To organize results +in descending order, pass ``Sort.DESCENDING`` as a second argument. +You can resolve sort order ties between identical property values +by passing an array of properties instead of a single property: in the +event of a tie, the SDK sorts the tied objects by subsequent +properties in order. + +.. note:: String Sorting Limitations + + The SDK uses non-standard sorting for upper and lowercase + letters, sorting them together rather than sorting uppercase first. + As a result, ``'- !"#0&()*,./:;?_+<=>123aAbBcC...xXyYzZ`` is the + actual sorting order in Realm. Additionally, sorting + strings only supports the ``Latin Basic``, ``Latin Supplement``, + ``Latin Extended A``, and ``Latin Extended B (UTF-8 range 0–591)`` + character sets. + +.. _java-limit-results: + +Limit Results +~~~~~~~~~~~~~ + +You can cap the number of query results to a specific maximum number +using the :java-sdk:`limit() ` +method: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.limit.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.limit.kt + :language: kotlin + :copyable: false + +Limited result collections automatically update like any other query +result. Consequently, objects might drop out of the collection as +underlying data changes. + +.. tip:: Pagination is Not Necessary for SDK Optimization + + Some databases encourage paginating results with limits to avoid + reading unnecessary data from disk or using too much memory. + + Since Atlas Device SDK queries are lazy, there is no need to + take such measures. The SDK only loads objects from query + results when they are explicitly accessed. + +.. tip:: Deleted Notifications in Limited Results + + :ref:`Collection notifications ` + report objects as deleted when they drop out of the result set. + This does not necessarily mean that they have been deleted from the + underlying database, just that they are no longer part of the + query result. + +.. _java-unique-results: + +Unique Results +~~~~~~~~~~~~~~ + +You can reduce query results to unique values for a given field or fields +using the :java-sdk:`distinct() +` method: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.unique.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.unique.kt + :language: kotlin + :copyable: false + +You can only call ``distinct()`` on integer, long, short, and ``String`` +fields; other field types will throw an exception. As with sorting, +you can specify multiple fields to resolve ties. + +.. _java-chain-queries: + +Chain Queries +~~~~~~~~~~~~~ + +You can apply additional filters to a results collection by calling the +:java-sdk:`where() ` method: + +.. tabs-drivers:: + + .. tab:: + :tabid: java + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.chain-queries.java + :language: java + :copyable: false + + .. tab:: + :tabid: java-kotlin + + .. literalinclude:: /examples/generated/java/local/FilterDataTest.snippet.chain-queries.kt + :language: kotlin + :copyable: false + +The ``where()`` method returns a ``RealmQuery`` that you can resolve into +a ``RealmResults`` using a ``find`` method. Filtered results can only +return objects of the same type as the original results set, but are +otherwise able to use any :ref:`filters `. diff --git a/source/sdk/crud/query-engines/filter-data-linq.txt b/source/sdk/crud/query-engines/filter-data-linq.txt index 508b0ed878..7aeecb5aba 100644 --- a/source/sdk/crud/query-engines/filter-data-linq.txt +++ b/source/sdk/crud/query-engines/filter-data-linq.txt @@ -1,12 +1,20 @@ -.. _dotnet-filter-data: -.. _dotnet-filter-queries-based-on-object-properties: -.. _dotnet-filter-results: -.. _dotnet-client-query-engine: -.. _dotnet-linq: +.. _sdks-dotnet-linq: -=========================== -Filter and Sort Data - LINQ -=========================== +================================ +Filter Data with LINQ - .NET SDK +================================ + +.. meta:: + :description: Atlas Device SDK for .NET provides a LINQ query engine for an idiomatic query experience in C#. + :keywords: Realm, .NET SDK, code example + +.. facet:: + :name: genre + :values: reference + +.. facet:: + :name: programming_language + :values: csharp .. contents:: On this page :local: @@ -14,4 +22,242 @@ Filter and Sort Data - LINQ :depth: 2 :class: singlecol -Placeholder page for querying data in .NET SDK using LINQ. +The Atlas Device SDK query engine implements standard `LINQ +`__ +syntax. + +There are several operators available to filter an SDK collection with LINQ. +Filters work by evaluating an operator expression for every object in the +collection being filtered. If the expression resolves to ``true``, the SDK +includes the object in the results collection. + +An expression consists of one of the following: + +- The name of a property of the object currently being evaluated +- An operator +- A value of any type used by the SDK (string, date, number, boolean, etc.) + +.. note:: + + The SDK does not currently support all of the LINQ operators. Refer to the + :ref:`sdks-dotnet-unsupported-linq` section on this page for a list of + those unsupported operators. + +Comparison Operators +~~~~~~~~~~~~~~~~~~~~ + +Value comparisons + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Operator + - Description + + * - | ``==`` + - Evaluates to ``true`` if the left-hand expression is equal to the + right-hand expression. + + * - | ``>`` + - Evaluates to ``true`` if the left-hand numerical or date expression is + greater than the right-hand numerical or date expression. For dates, this + evaluates to ``true`` if the left-hand date is later than the right-hand + date. + + * - | ``>=`` + - Evaluates to ``true`` if the left-hand numerical or date expression is + greater than or equal to the right-hand numerical or date expression. For + dates, this evaluates to ``true`` if the left-hand date is later than or + the same as the right-hand date. + + * - | ``<`` + - Evaluates to ``true`` if the left-hand numerical or date expression is + less than the right-hand numerical or date expression. For dates, this + evaluates to ``true`` if the left-hand date is earlier than the + right-hand date. + + * - | ``<=`` + - Evaluates to ``true`` if the left-hand numeric expression is less than + or equal to the right-hand numeric expression. For dates, this evaluates + to ``true`` if the left-hand date is earlier than or the same as the + right-hand date. + + * - | ``!=`` + - Evaluates to ``true`` if the left-hand expression is not equal to the + right-hand expression. + +.. example:: + + The following example uses the query engine's + comparison operators to: + + - Find high priority tasks by comparing the value of the ``priority`` property + value with a threshold number, above which priority can be considered high. + - Find just-started or short-running tasks by seeing if the ``progressMinutes`` + property falls within a certain range. + - Find unassigned tasks by finding tasks where the ``assignee`` property is + equal to ``null``. + - Find tasks assigned to specific teammates Ali or Jamie by seeing if the + ``assignee`` property is in a list of names. + + .. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.comparisons.cs + :language: csharp + +Logical Operators +~~~~~~~~~~~~~~~~~ + +You can use the logical operators listed in the following table to make compound +predicates: + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Operator + - Description + + * - | ``&&`` + - Evaluates to ``true`` if both left-hand and right-hand expressions are + ``true``. + + * - | ``!`` + - Negates the result of the given expression. + + * - | ``||`` + - Evaluates to ``true`` if either expression returns ``true``. + +.. example:: + + We can use the query language's logical operators to find + all of Ali's completed tasks. That is, we find all tasks + where the ``assignee`` property value is equal to 'Ali' AND + the ``isComplete`` property value is ``true``: + + .. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.logical.cs + :language: csharp + +String Operators +~~~~~~~~~~~~~~~~ + +You can compare string values using the string operators listed in the following +table. Regex-like wildcards allow more flexibility in search. + +.. list-table:: + :header-rows: 1 + :widths: 40 60 + + * - Operator + - Description + + * - ``StartsWith`` + - Evaluates to ``true`` if the left-hand string expression begins with the + right-hand string expression. This is similar to ``contains``, but only + matches if the left-hand string expression is found at the beginning of + the right-hand string expression. + + * - | ``EndsWith`` + - Evaluates to ``true`` if the left-hand string expression ends with the + right-hand string expression. This is similar to ``contains``, but only + matches if the left-hand string expression is found at the very end of + the right-hand string expression. + + * - | ``Like`` + - Evaluates to ``true`` if the left-hand string expression + matches the right-hand string wildcard string + expression. A wildcard string expression is a string + that uses normal characters with two special wildcard + characters: + + - The ``*`` wildcard matches zero or more of any character + - The ``?`` wildcard matches any character. + + For example, the wildcard string "d?g" matches "dog", + "dig", and "dug", but not "ding", "dg", or "a dog". + + * - | ``Equals`` + - Evaluates to ``true`` if the left-hand string is + `lexicographically `_ + equal to the right-hand string. + + * - | ``Contains`` + - Evaluates to ``true`` if the left-hand string expression is found anywhere + in the right-hand string expression. + + * - | ``string.IsNullOrEmpty`` + - Evaluates to ``true`` if the left-hand string expression is null or empty. + Note that ``IsNullOrEmpty()`` is a static method on ``string``. + +.. example:: + + The following examples use the query engine's string operators to find + tasks: + + .. literalinclude:: /examples/generated/dotnet/QueryEngineExamples.snippet.strings.cs + :language: csharp + +.. important:: Case Comparisons + + When evaluating strings, the second parameter in all functions *except* ``Like`` + must be either ``StringComparison.OrdinalIgnoreCase`` or + ``StringComparison.Ordinal``. For the ``Like()`` method, the second + parameter is a boolean value (where "true" means "case sensitive"). + +.. _dotnet-linq-fts: + +Full Text Search +~~~~~~~~~~~~~~~~ + +You can use LINQ to query on properties that have :ref:`enabled Full-Text Search +` (FTS). To query these properties, use +:dotnet-sdk:`QueryMethods.FullTextSearch +`. +The following examples query the ``Person.Biography`` field: + +.. literalinclude:: /examples/generated/dotnet/Indexing.snippet.linq-query-fts.cs + :language: csharp + +.. _sdks-dotnet-unsupported-linq: + +Unsupported LINQ Operators +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following LINQ operators are not currently supported by the SDK: + +.. list-table:: + :header-rows: 1 + :widths: 40 60 + + * - Category + - Unsupported Operators + + * - | Concatenation + - - ``Concat`` + - ``Join``. While ``Join`` is not supported, it is not needed with + the SDK. Instead of using keys in a Join statement, as you would in + a traditional relational database, you can reference another type + as a property. For more information, refer to :ref:`sdks-relationships`. + - ``GroupJoin`` + + * - | Grouping + - - ``GroupBy`` + + * - | Partitioning + - - ``Take`` + - ``Skip`` + - ``TakeWhile`` + - ``SkipWhile`` + + * - | Projection + - - ``SelectMany`` + - ``Select``, with one exception: when used with the query syntax, ``Select`` + is supported as long as you select the Realm object itself and not a + derivative: + + ``var tasks = from t in realm.All() where t.Assignee == "Caleb" select t;`` + + * - | Sets + - - ``Distinct`` + - ``Union`` + - ``Intersect`` + - ``Except`` diff --git a/source/sdk/crud/query-engines/filter-data-swift-sdk.txt b/source/sdk/crud/query-engines/filter-data-swift-sdk.txt index bd79198a2b..3a315fe16e 100644 --- a/source/sdk/crud/query-engines/filter-data-swift-sdk.txt +++ b/source/sdk/crud/query-engines/filter-data-swift-sdk.txt @@ -122,6 +122,8 @@ object in the collection being queried. If the expression resolves to ``true``, the SDK includes the object in the results collection. +.. _sdks-swift-where-comparison-operators: + Comparison Operators ```````````````````` @@ -299,7 +301,7 @@ This operator evaluates to ``true`` if: :language: swift For more information about querying geospatial data, refer to -:ref:`sdks-query-geospatial`. +:ref:`sdks-read-filter-geospatial-data`. Aggregate Operators ``````````````````` @@ -475,6 +477,8 @@ object in the collection being filtered. If the expression resolves to ``true``, the SDK includes the object in the results collection. +.. _sdks-swift-nspredicate-comparison-operators: + Comparison Operators ```````````````````` @@ -485,7 +489,7 @@ values. The type on both sides of the operator must be equivalent. For example, comparing an :ref:`ObjectId with string - ` will result in a precondition failure + ` will result in a precondition failure with a message like: .. code-block:: @@ -727,7 +731,7 @@ This operator evaluates to ``true`` if: :language: swift For more information about querying geospatial data, refer to -:ref:`sdks-query-geospatial`. +:ref:`sdks-read-filter-geospatial-data`. Aggregate Operators ``````````````````` diff --git a/source/sdk/crud/query-engines/realm-query-language.txt b/source/sdk/crud/query-engines/realm-query-language.txt index cc18750539..3729ce07e6 100644 --- a/source/sdk/crud/query-engines/realm-query-language.txt +++ b/source/sdk/crud/query-engines/realm-query-language.txt @@ -40,8 +40,8 @@ engine. For more information about SDK-specific query methods, refer to The following SDKs also support language-specific idiomatic APIs for querying databases: -- :ref:`Fluent Interface (Java SDK) ` -- :ref:`LINQ (.NET SDK) ` +- :ref:`Fluent Interface (Java SDK) ` +- :ref:`LINQ (.NET SDK) ` In addition to using RQL in your client code, you can also use RQL in :ref:`Realm Studio ` to browse for data. @@ -935,6 +935,30 @@ The following example uses subquery filters to find projects based on the subquery results collection. You can compare the count with the number ``0`` to return all matching objects. +.. _rql-collections-in-mixed-queries: + +Mixed Properties with Nested Data +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can query nested collections of mixed properties using the same syntax as +you would for a normal :ref:`list ` or +:ref:`dictionary ` collection. + +For nested collections, you can also use: + +- Bracket notation, which provides the following collection query operators: + + - ``[FIRST]`` and [``LAST``]: match the first or last elements within the collection. + - ``[]``: match the element at the specific index. + - ``[*]``: match any element within the collection (this operator assumes a + collection type at that path). + - ``[SIZE]``: match the collection length. + +- The ``@type`` operator, which supports the following values: + + - ``array`` and ``list``: match a list collection. + - ``dictionary`` and ``object``: match a map collection. + - ``collection``: match a list or a map collection. .. _rql-objectid-uuid-operators: diff --git a/source/sdk/crud/read.txt b/source/sdk/crud/read.txt index 56ea7c6e1a..be56acf743 100644 --- a/source/sdk/crud/read.txt +++ b/source/sdk/crud/read.txt @@ -4,58 +4,899 @@ Read Objects ============ +.. toctree:: + :titlesonly: + + Read Properties + .. meta:: :description: Read objects from the database by object type. Query by property to filter results. - :keywords: code example + :keywords: Realm, C++ SDK, Flutter SDK, Kotlin SDK, Java SDK, .NET SDK, Node.js SDK, Swift SDK, code example .. facet:: :name: genre :values: reference +.. facet:: + :name: programming_language + :values: cpp, csharp, dart, java, javascript/typescript, kotlin, objective-c, swift + .. contents:: On this page :local: :backlinks: none :depth: 2 :class: singlecol -Placeholder page for content related to reading realm objects. +.. tabs-selector:: drivers + +This page describes how to query and read objects from the a database +with Atlas Device SDK. You can read the data that you have +:ref:`written ` to the database by finding, +filtering, and sorting objects. + +A read from the database generally consists of the following steps: + +- Get all objects of a certain type from the database instance. +- Optionally, filter the results. +- Optionally, sort the results. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-intro-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-intro-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-intro-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-intro-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-intro-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-intro-js-ts-description.rst + + .. tab:: + :tabid: kotlin -.. _sdks-find-object-by-primary-key: + .. include:: /includes/api-details/kotlin/crud/read-intro-description.rst -Find an Object by Primary Key -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-intro-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-intro-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-intro-js-ts-description.rst + +The syntax for read operations is the same for synced and non-synced databases. + +For information related to reading specific property types, including finding +an object by primary key, refer to :ref:`sdks-crud-read-properties`. + +.. _sdks-read-characteristics: + +Read Characteristics +-------------------- + +Design your app's data access patterns around these read characteristics to +read data as efficiently as possible. .. _sdks-read-results: SDK Results Collections ------------------------ +~~~~~~~~~~~~~~~~~~~~~~~ + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-sdk-results-collections-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-sdk-results-collections-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-sdk-results-collections-js-ts-description.rst + +.. _sdks-results-are-not-copies: + +Results Are Not Copies +`````````````````````` + +Unless you are working with frozen objects, results to a query are not copies +of your data. Modifying the results of a query modifies the data on disk +directly. This memory mapping also means that results are **live**: that is, +they always reflect the current state on disk. + +For more details about live versus frozen objects, refer to +:ref:`sdks-live-and-frozen-objects`. + +.. _sdks-results-are-lazy: + +Results Are Lazy +```````````````` + +The SDK only runs a query when you actually request the results of that query. +This lazy evaluation enables you to write highly performant code for handling +large data sets and complex queries. You can chain several filter operations +without requiring extra work to process the intermediate state. + +.. _sdks-references-retained: + +References Are Retained +``````````````````````` + +Atlas Device SDK automatically retains all of an object's :ref:`relationships +` as direct references. This enables you to traverse your +graph of relationships directly through the results of a query. + +A **direct reference**, or pointer, allows you to access a related object's +properties directly through the reference. + +Other databases typically copy objects from database storage into application +memory when you need to work with them directly. Because application objects +contain direct references, you are left with a choice: copy the object +referred to by each direct reference out of the database in case it's needed, +or copy the foreign key for each object and query for the object with that key +if it's accessed. If you choose to copy referenced objects into application +memory, you can use up a lot of resources for objects that are never accessed. +If you copy only the foreign key, referenced object lookups can cause your +application to slow down. + +The SDK bypasses all of this using zero-copy live objects. Database object +accessors point directly into database storage using memory mapping, so there +is no distinction between the objects in the database and the results of your +query in application memory. Because of this, you can traverse direct +references across an entire database from any query result. + +.. _sdks-limiting-results: + +Limiting Query Results +`````````````````````` + +As a result of lazy evaluation, you do not need any special mechanism to +limit query results with the SDK. For example, if your query matches thousands +of objects, but you only want to load the first ten, access only the first ten +elements of the results collection. None of the remaining objects are loaded +into memory. + +.. _sdks-pagination: + +Pagination +`````````` + +With lazy evaluation, pagination is very direct. Consider a query that matches +thousands of objects in your realm. Your app displays one hundred objects per +page. To advance to any page, access the elements of the results collection +starting at the index that corresponds to the target page. + +.. _sdks-read-database-objects: + +Read Database Objects +--------------------- + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-database-objects-js-ts-procedure.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-database-objects-procedure.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-database-objects-js-ts-procedure.rst + +.. _sdks-read-methods: + +Read Object Methods +------------------- + +.. _sdks-read-all-objects-of-type: + +Read All Objects of a Type +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Because results sets are homogenous by type, most read operations begin with +querying for all objects of a type. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-all-objects-of-type-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-all-objects-of-type-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-all-objects-of-type-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-all-objects-of-type.rst + +.. _sdks-read-query-objects: + +Filter or Query Objects +~~~~~~~~~~~~~~~~~~~~~~~ + +A **filter** selects a subset of results based on the value(s) of one or more +object properties. The most common use case is to find objects where a certain +property matches a certain value. Additionally, you can compare strings, +aggregate over collections of numbers, and use logical operators to build up +complex queries. + +The SDK provides several full-featured query engines you +can use to define filters. The core query engine uses :ref:`Realm Query +Language (RQL) ` to construct queries. RQL is a +string-based query language that you can use to retrieve objects from the +database. Some of the SDK languages provide special query APIs that provide +idiomatic query syntax and features. The available query APIs include: + +- :ref:`RQL `: C++, C#, Dart, Java, JavaScript, Kotlin, + TypeScript +- :ref:`LINQ `: C# +- :ref:`Type-Safe and NSPredicate Queries `: Swift, + Objective-C +- :ref:`Fluent Interface `: Java, Kotlin (Java SDK) + +For more details about the supported operators when using each of these query +APIs, refer to the query engine for your preferred language. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-filter-or-query-objects-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-filter-or-query-objects-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-filter-or-query-objects-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-filter-or-query-objects-java-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-filter-or-query-objects-kotlin-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-filter-or-query-objects-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-filter-or-query-objects-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-filter-or-query-objects-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-filter-or-query-objects-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-filter-or-query-objects-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-filter-or-query-objects.rst + +.. tip:: Filter on Related and Embedded Object Properties + + To filter a query based on a property of an :ref:`embedded object + ` or a :ref:`related object + `, use dot-notation as if it were in a regular, + nested object. + +.. _sdks-read-access-results: + +Access Results +~~~~~~~~~~~~~~ + +When you perform a read operation, such as getting all objects of a type or +performing a query, the SDK returns a results collection that contains 0 +or more objects. + +The SDK provides convenience methods to make it easier to work with the results. +The available methods vary depending on the SDK language. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-access-results-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-access-results-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-access-results-description.rst -Placeholder. Add some concept information about results being a special SDK -auto-updating collection type for read operations (except in Kotlin, where it's -frozen). + .. tab:: + :tabid: java -.. _sdks-query-engines: + .. include:: /includes/api-details/java/crud/read-access-results-description.rst -Filter Data ------------ + .. tab:: + :tabid: java-kotlin -Placeholder. Add some concept information about the SDK having query engines, -and the one you use varying depending on the SDK you're using. i.e.: + .. include:: /includes/api-details/java/crud/read-access-results-description.rst -- RQL (C++ (subset only), C#, Dart, JS, Kotlin, TS, maybe also Java/Java Kotlin?) -- LINQ (C#) -- Swift SDK (Swift & Objective-C Type-Safe queries and NS Predicate queries) -- Java (Java & Kotlin, Fluent Interface) + .. tab:: + :tabid: javascript -Read Relationship Properties ----------------------------- + .. include:: /includes/api-details/javascript/crud/read-access-results-js-ts-description.rst -.. _sdks-query-inverse-relationships: + .. tab:: + :tabid: kotlin -Query Inverse Relationships -~~~~~~~~~~~~~~~~~~~~~~~~~~~ + .. include:: /includes/api-details/kotlin/crud/read-access-results-description.rst -.. _sdks-query-geospatial: + .. tab:: + :tabid: objectivec -Query Geospatial Data + .. include:: /includes/api-details/objectivec/crud/read-access-results-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-access-results-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-access-results-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-access-results.rst + +.. _sdks-read-chain-queries: + +Chain Queries +~~~~~~~~~~~~~ + +Because results are lazily evaluated, you can chain several queries together. +Unlike traditional databases, this does not require a separate trip to the +database for each successive query. + +.. The tab set below doesn't contain API details - just description of examples +.. Most are empty because they lack examples + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + .. tab:: + :tabid: csharp + + + .. tab:: + :tabid: dart + + + .. tab:: + :tabid: java + + + .. tab:: + :tabid: java-kotlin + + + .. tab:: + :tabid: javascript + + + .. tab:: + :tabid: kotlin + + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-chain-queries-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-chain-queries-description.rst + + .. tab:: + :tabid: typescript + + + +.. include:: /includes/sdk-examples/crud/read-chain-queries.rst + +.. _sdks-read-sort: + +Sort +~~~~ + +A sort operation allows you to configure the order in which the SDK +returns queried objects. You can sort based on one or more properties of the +objects in the results collection. The SDK only guarantees a consistent order +of results if you explicitly sort them. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-sort-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-sort-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-sort-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-sort-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-sort-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-sort-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-sort-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-sort-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-sort-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-sort-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-sort.rst + +.. tip:: Sort on Related and Embedded Object Properties + + To sort a query based on a property of an :ref:`embedded object + ` or a :ref:`related object + `, use dot-notation as if it were in a regular, + nested object. + +.. _sdks-read-limit: + +Limit +~~~~~ + +SDK languages that use the Realm Query Language query engine can limit query +results using the :ref:`RQL LIMIT() operator `. + +Note that you can't use :ref:`parameterized queries ` +in RQL LIMIT() clauses. Instead, use strings or string interpolation. + +.. Languages that use RQL and don't have a separate limit method don't need details here + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-limit-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-limit-description.rst + + .. tab:: + :tabid: dart + + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-limit-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-limit-description.rst + + .. tab:: + :tabid: javascript + + + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-limit-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-limit-not-supported.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-limit-not-supported.rst + + .. tab:: + :tabid: typescript + + +.. include:: /includes/sdk-examples/crud/read-limit.rst + +.. _sdks-read-aggregate: + +Aggregate +~~~~~~~~~ + +You can aggregate results, which reduces results to a single value based on a +specified numerical property or collection. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-aggregate-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-aggregate-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-aggregate-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-aggregate-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-aggregate-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-aggregate-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-aggregate-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-aggregate-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-aggregate-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-aggregate-description.rst + +.. include:: /includes/sdk-examples/crud/read-aggregate.rst + +.. _sdks-read-section-query-results: + +Section Query Results ~~~~~~~~~~~~~~~~~~~~~ + +Some of the SDK languages provide an API to split results collections into +individual sections. Each section corresponds to a key generated from a +property on the object it represents. This simplifies working with logical +subsets of query results. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-section-query-results-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-section-query-results-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/generic/crud/read-section-query-results-not-supported.rst + +.. _sdks-read-query-projections: + +Query Projections +~~~~~~~~~~~~~~~~~ + +If your app defines a :ref:`class projection ` +to work with persisted data in a different way in a view model or based on +certain business logic, you can query on that projection. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-projections-missing-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-projections-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/generic/crud/read-query-projections-not-supported.rst + +.. tip:: + + Don't do derived queries on top of class projection results. Instead, run a + query against the SDK object directly and then project the result. If you + try to do a derived query on top of class projection results, querying a + field with the same name and type as the original object works, but querying + a field with a name or type that isn't in the original object fails. diff --git a/source/sdk/crud/read/read-properties.txt b/source/sdk/crud/read/read-properties.txt new file mode 100644 index 0000000000..3a5e620ad0 --- /dev/null +++ b/source/sdk/crud/read/read-properties.txt @@ -0,0 +1,1166 @@ +.. _sdks-crud-read-properties: + +=============== +Read Properties +=============== + +.. meta:: + :description: Read and query specific property types, or properties with special behaviors. + :keywords: Realm, C++ SDK, Flutter SDK, Kotlin SDK, Java SDK, .NET SDK, Node.js SDK, Swift SDK, code example + +.. facet:: + :name: genre + :values: reference + +.. facet:: + :name: programming_language + :values: cpp, csharp, dart, java, javascript/typescript, kotlin, objective-c, swift + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +.. tabs-selector:: drivers + +This page describes how to read and query specific property types, and +properties that have special behaviors, with Atlas Device SDK. + +For other information related to reading data from the database, refer to: + +- :ref:`sdks-crud-read`: General information about read operations, including + information on how to access, sort, and limit results. +- Information about specific query APIs and supported operators: + + - :ref:`RQL `: C++, C#, Dart, Java, JavaScript, Kotlin, + TypeScript + - :ref:`LINQ `: C# + - :ref:`Type-Safe and NSPredicate Queries `: Swift, + Objective-C + - :ref:`Fluent Interface `: Java, Kotlin (Java SDK) + +.. _sdks-read-filter-by-property-type: + +Filter by Property Type +----------------------- + +.. _sdks-read-filter-by-collection: + +Query Collections (List, Set, Dictionary) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. _sdks-read-list: + +Query List Properties +````````````````````` + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-query-list-properties-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-list-properties-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-query-list-properties-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-query-list-properties.rst + +.. _sdks-read-set: + +Query Set Properties +```````````````````` + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-set-properties-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/typescript/crud/read-query-set-properties-description.rst + +.. include:: /includes/sdk-examples/crud/read-query-set-properties.rst + +.. _sdks-read-dictionary: + +Query Dictionary Properties +``````````````````````````` + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-query-dictionary-properties-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-dictionary-properties-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-query-dictionary-properties-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-query-dictionary-properties.rst + +.. _sdks-read-filter-geospatial-data: + +Query Geospatial Data +~~~~~~~~~~~~~~~~~~~~~ + +The SDK provides several shapes to simplify querying +:ref:`geospatial data `. You can use the +circle, polygon, and box shapes to set the boundaries for your geospatial +data queries. + +To query geospatial data: + +1. Define a geospatial shape representing the bounds within which you want to + query data. +2. Use the geospatial shape in a query with the relevant geospatial query + operators. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-geospatial-data-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-query-geospatial-data-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-query-geospatial-data-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-geospatial-data-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-geospatial-data-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-geospatial-data-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-query-geospatial-data-js-ts-description.rst + +Define Geospatial Shapes +```````````````````````` + +.. tabs:: + + .. tab:: Circle + :tabid: circle + + .. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-define-geospatial-shapes-circle-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-define-geospatial-shapes-circle-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-define-geospatial-shapes-circle-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-define-geospatial-shapes-circle-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-define-geospatial-shapes-circle-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-define-geospatial-shapes-circle-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-define-geospatial-shapes-circle-js-ts-description.rst + + .. include:: /includes/sdk-examples/crud/read-define-geospatial-shapes-circle.rst + + .. figure:: /images/geocircles.png + :alt: Two GeoCircles + :width: 150 + :lightbox: + + .. tab:: Box + :tabid: box + + .. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-define-geospatial-shapes-box-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-define-geospatial-shapes-box-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-define-geospatial-shapes-box-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-define-geospatial-shapes-box-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-define-geospatial-shapes-box-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-define-geospatial-shapes-box-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-define-geospatial-shapes-box-js-ts-description.rst + + .. include:: /includes/sdk-examples/crud/read-define-geospatial-shapes-box.rst + + .. figure:: /images/geoboxes.png + :alt: 2 GeoBoxes + :width: 150 + :lightbox: + + .. tab:: Polygon + :tabid: polygon + + .. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-define-geospatial-shapes-polygon-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-define-geospatial-shapes-polygon-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-define-geospatial-shapes-polygon-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-define-geospatial-shapes-polygon-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-define-geospatial-shapes-polygon-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-define-geospatial-shapes-polygon-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-define-geospatial-shapes-polygon-js-ts-description.rst + + Holes have the following restrictions: + + - Holes may not cross. The boundary of a hole may not intersect both the + interior and the exterior of any other hole. + - Holes may not share edges. If a hole contains an edge AB, then no other + hole may contain it. + - Holes may share vertices. However, no vertex may appear twice in a + single hole. + - No hole may be empty. + - Only one nesting is allowed. + + .. include:: /includes/sdk-examples/crud/read-define-geospatial-shapes-polygon.rst + + .. figure:: /images/geopolygons.png + :alt: 3 GeoPolygons + :width: 250 + :lightbox: + +Query with Geospatial Shapes +```````````````````````````` + +After you define a geospatial shape, you can use these shapes in a geospatial +query. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-with-geospatial-shapes-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-query-with-geospatial-shapes-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-geospatial-data-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-query-with-geospatial-shapes-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-with-geospatial-shapes-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-with-geospatial-shapes-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-with-geospatial-shapes-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-query-with-geospatial-shapes-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-query-with-geospatial-shapes.rst + +.. figure:: /images/geopoints.png + :alt: 2 GeoPoints + :width: 150 + :lightbox: + +.. tabs:: + + .. tab:: Circle + :tabid: circle + + .. include:: /includes/sdk-examples/crud/read-query-with-geospatial-shapes-circle.rst + + .. figure:: /images/geocircles-query.png + :alt: Querying a GeoCircle example. + :width: 150 + :lightbox: + + .. tab:: Box + :tabid: box + + .. include:: /includes/sdk-examples/crud/read-query-with-geospatial-shapes-box.rst + + .. figure:: /images/geoboxes-query.png + :alt: Querying a GeoBox example. + :width: 150 + + .. tab:: Polygon + :tabid: polygon + + .. include:: /includes/sdk-examples/crud/read-query-with-geospatial-shapes-polygon.rst + + .. figure:: /images/geopolygons-query.png + :alt: Querying a GeoPolygon example. + :width: 150 + :lightbox: + +.. _sdks-read-filter-mixed-property: + +Query a Mixed Property +~~~~~~~~~~~~~~~~~~~~~~ + +A :ref:`sdks-mixed-data-type` property represents a polymorphic value that can +hold any one of its supported data types at a particular moment. You can query +a mixed property the same way you would any property. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-query-mixed-properties-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-mixed-properties-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-query-mixed-properties-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-query-mixed-properties.rst + +Query Nested Collections of Mixed Data +`````````````````````````````````````` + +A mixed data type can hold collections (a list or dictionary, but *not* a set) +of mixed elements. You can use mixed collections to model unstructured or +variable data. For more information, refer to :ref:``. + +- You can nest mixed collections up to 100 levels. +- You can query mixed collection properties and + :ref:`register a listener for changes `, as you + would a normal collection. + +- You can find and update individual mixed collection elements +- You *cannot* store sets or embedded objects in mixed collections. + +For details about supported operators and list comparisons, refer to the +:ref:`rql-collections-in-mixed-queries` documentation. + +.. _sdks-read-query-custom-persistable-property: + +Query a Custom Persistable Property +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When you use :ref:`type projection ` to map unsupported +types to supported types, accessing those properties is often based on the +persisted type. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-custom-persistable-property-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-custom-persistable-property-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/generic/crud/read-query-custom-persistable-property-not-supported.rst + +.. _sdks-read-filter-property-behaviors: + +Filter by Property Behaviors +---------------------------- + +.. _sdks-read-find-object-by-primary-key: + +Find an Object by Primary Key +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Finding a specific object by its :ref:`primary key ` is a +common operation, which some of the SDK languages support through a dedicated +method. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/cpp/crud/read-find-object-by-primary-key-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-find-object-by-primary-key-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-filter-or-query-objects-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-find-object-by-primary-key-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-find-object-by-primary-key-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-find-object-by-primary-key-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-find-object-by-primary-key-not-supported.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-find-object-by-primary-key-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-find-object-by-primary-key-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-find-object-by-primary-key-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-find-object-by-primary-key.rst + +.. tip:: Device Sync Always Uses _id as Primary Key + + If you use Atlas Device Sync, you can always query by the primary key + field ``_id``. This is because the Device Sync data model requires + objects have a primary key named ``_id``. For more information, refer to + :ref:``. + +.. _sdks-read-filter-by-remapped-property-name: + +Filter by Remapped Property Name +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If your data model includes stored property names that you have +:ref:`mapped to different names `, you can filter by +both the mapped property name used in your code and the stored property +name that's persisted in the database. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. tab:: + :tabid: csharp + + + + .. tab:: + :tabid: dart + + + + .. tab:: + :tabid: java + + + + .. tab:: + :tabid: java-kotlin + + + + .. tab:: + :tabid: javascript + + + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-filter-by-remapped-property-name-description.rst + + .. tab:: + :tabid: objectivec + + + + .. tab:: + :tabid: swift + + + + .. tab:: + :tabid: typescript + + + +.. include:: /includes/sdk-examples/crud/read-filter-by-remapped-property-name.rst + +.. _sdks-read-filter-by-fts: + +Filter a Full-Text Search Property +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If your data model includes a :ref:`Full-Text Search (FTS) ` +index property, you can filter by the property using the ``TEXT`` predicate. +Words in the query are converted to tokens by a tokenizer using the following +rules: + +- Tokens can only consist of characters from ASCII and the Latin-1 + supplement (western languages). All other characters are considered whitespace. +- Words split by a hyphen (``-``) are split into two tokens. For example, + ``full-text`` splits into ``full`` and ``text``. +- Tokens are diacritics- and case-insensitive. + +You can search for an entire word or phrase, or limit your results with the +following characters: + +- Exclude results for a word by placing the ``-`` character in front of the + word. For example, ``fiction -science`` would include all search results + for ``fiction`` and exclude those that include the word ``science``. +- Specify prefixes by placing the ``*`` character at the end of a word. For + example, ``fict*`` would include all search results for ``fiction`` and + ``fictitious``. The SDK does *not* currently support suffix searches. + +The SDK returns a Boolean match for the specified query, instead of a +relevance-based match. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + .. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-filter-full-text-search-property-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-filter-full-text-search-property-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-filter-full-text-search-property-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-filter-full-text-search-property-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/typescript/crud/read-filter-full-text-search-property-description.rst + +.. include:: /includes/sdk-examples/crud/read-filter-full-text-search-property.rst + +.. _sdks-read-query-relationship-properties: + +Filter Relationships +~~~~~~~~~~~~~~~~~~~~ + +.. _sdks-read-query-to-one-relationship: + +Query a To-One Relationship +``````````````````````````` + +A :ref:`to-one relationship ` property maps to +a single instance of another object type. You can filter by the relationship +property using dot notation, the same way you would a nested object. + +The SDK requires to-one relationships to be optional. Your code should handle +the possible nil or null value. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-to-one-relationship-description.rst + + .. tab:: + :tabid: dart + + + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-query-to-one-relationship-java-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-query-to-one-relationship-kotlin-description.rst + + .. tab:: + :tabid: javascript + + + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-to-one-relationship-description.rst + + .. tab:: + :tabid: objectivec + + + + .. tab:: + :tabid: swift + + + + .. tab:: + :tabid: typescript + + + +.. include:: /includes/sdk-examples/crud/read-query-to-one-relationship.rst + +.. _sdks-read-query-to-many-relationship: + +Query a To-Many Relationship +```````````````````````````` + +:ref:`To-many relationships ` properties are +collections to another object type: + +- :ref:`List ` +- :ref:`Set ` +- :ref:`Dictionary ` + +You can filter by and iterate through the relationship property the same way +you would any other collection property. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-to-many-relationship-description.rst + + .. tab:: + :tabid: dart + + + + .. tab:: + :tabid: java + + + + .. tab:: + :tabid: java-kotlin + + + + .. tab:: + :tabid: javascript + + + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-to-many-relationship-description.rst + + .. tab:: + :tabid: objectivec + + + + .. tab:: + :tabid: swift + + + + .. tab:: + :tabid: typescript + + + +.. include:: /includes/sdk-examples/crud/read-query-to-many-relationship.rst + +.. _sdks-read-query-inverse-relationships: + +Query an Inverse Relationship +````````````````````````````` + +An **inverse relationship** links an object back to any other objects that refer +to it in a defined to-one or to-many relationship. Relationship definitions are +unidirectional, so you must explicitly define a property in the object's model +as an inverse relationship. + +When you follow an inverse relationship, the result may include zero or more +objects. You must access the collection to work with an originating object. + +.. tabs-drivers:: + + .. tab:: + :tabid: cpp-sdk + + + + .. tab:: + :tabid: csharp + + .. include:: /includes/api-details/csharp/crud/read-query-inverse-relationship-description.rst + + .. tab:: + :tabid: dart + + .. include:: /includes/api-details/dart/crud/read-query-inverse-relationship-description.rst + + .. tab:: + :tabid: java + + .. include:: /includes/api-details/java/crud/read-query-inverse-relationship-java-description.rst + + .. tab:: + :tabid: java-kotlin + + .. include:: /includes/api-details/java/crud/read-query-inverse-relationship-kotlin-description.rst + + .. tab:: + :tabid: javascript + + .. include:: /includes/api-details/javascript/crud/read-query-inverse-relationship-js-ts-description.rst + + .. tab:: + :tabid: kotlin + + .. include:: /includes/api-details/kotlin/crud/read-query-inverse-relationship-description.rst + + .. tab:: + :tabid: objectivec + + .. include:: /includes/api-details/objectivec/crud/read-query-inverse-relationship-description.rst + + .. tab:: + :tabid: swift + + .. include:: /includes/api-details/swift/crud/read-query-inverse-relationship-description.rst + + .. tab:: + :tabid: typescript + + .. include:: /includes/api-details/javascript/crud/read-query-inverse-relationship-js-ts-description.rst + +.. include:: /includes/sdk-examples/crud/read-query-inverse-relationship.rst diff --git a/source/sdk/model-data/property-types.txt b/source/sdk/model-data/property-types.txt index 50b82a1107..63612c1af8 100644 --- a/source/sdk/model-data/property-types.txt +++ b/source/sdk/model-data/property-types.txt @@ -95,3 +95,8 @@ Other Property Types Define an Enum Property ~~~~~~~~~~~~~~~~~~~~~~~ + +.. _sdks-type-projection: + +Map Unsupported Types to Supported Types +---------------------------------------- diff --git a/source/sdk/quick-start.txt b/source/sdk/quick-start.txt index eb855cd9aa..240b6dcd23 100644 --- a/source/sdk/quick-start.txt +++ b/source/sdk/quick-start.txt @@ -201,7 +201,7 @@ To filter that same results collection: .. include:: /includes/sdk-examples/quick-start/quick-start-filter-objects.rst For more information about the SDK query engines, refer to -:ref:`sdks-query-engines`. +:ref:`sdks-read-query-objects`. Update ~~~~~~ diff --git a/source/sdk/sync/manage-sync-subscriptions.txt b/source/sdk/sync/manage-sync-subscriptions.txt index cca7dc8fc9..9b47996e79 100644 --- a/source/sdk/sync/manage-sync-subscriptions.txt +++ b/source/sdk/sync/manage-sync-subscriptions.txt @@ -61,8 +61,8 @@ You can construct subscription queries with Realm Query Language (RQL), or one of the SDK-idiomatic query engines. - :ref:`realm-query-language` -- :ref:`java-filter-data` -- :ref:`dotnet-linq` +- :ref:`sdks-java-filter-data` +- :ref:`sdks-dotnet-linq` - :ref:`sdks-filter-data-swift` .. important:: RQL Support in Sync Subscription Queries