[DOCS-15456] [Realm] Correct details on RQL page Created: 28/Jun/22  Updated: 04/Jan/23  Resolved: 12/Jul/22

Status: Closed
Project: Documentation
Component/s: Realm
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Alexander Stigsen Assignee: Ben Perlmutter
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
Related
Participants:
Days since reply: 1 year, 29 weeks, 5 days ago
Epic Link: DOCSP-20136
Story Points: 1

 Description   

Reading though the page on the Realm Query Language (https://www.mongodb.com/docs/realm/reference/realm-query-language/), I found a few missing and/or confusing parts:

  • Arithmetic is supported in expressions but not mentioned anywhere.
  • How do you do substitutions?
    • (NSPredicate uses %K for keypaths, %@ for variables. Not clear what to do in RQL)
  • Subqueries section should be after Collection operators
  • Between should be written as between {a, b} in the operator list (otherwise you have to hunt for an example to know how to actually define the range)

In general it is a bit confusing that this information is spread out over multiple pages. If you come from js, you will also hit into https://www.mongodb.com/docs/realm/sdk/node/advanced/query-engine/ and https://www.mongodb.com/docs/realm/sdk/node/examples/read-and-write-data/#std-label-node-filter-queries, both of which contains an incomplete subset of the information on the RQL page. It would be nice if they could be consolidated.



 Comments   
Comment by Ben Perlmutter [ 15/Jul/22 ]

thx for additional feedback and clarification on these operators. i'm actually working on another ticket to expand RQL documentation, so will loop this feedback into that ticket, DOCSP-20137.  

Comment by Alexander Stigsen [ 14/Jul/22 ]

Thanks. The changes look good.

It is still missing putting the section about subqueries in a more appropriate location. Since it only works on collections, it should really be listed under the collection operators (also since ANY, ALL and NONE really are shortcuts for something that would otherwise be expressed as a subquery).

Might also be worth adding a note about why you would use a subquery over the generic collection operators (if you need to match each object on multiple conditions, and/or specifically need the count).

Users are often confused over the subtle difference between:

"ANY tasks.isComplete == false AND ANY tasks.assignee == 'Alex'"

"SUBQUERY(tasks, $task, $task.isComplete == false AND $task.assignee == 'Alex').@count > 0"

(the first will run as two separate conditions, so not ensuring that the matches are on the same object in the list)

Comment by Ben Perlmutter [ 12/Jul/22 ]

merged and deployed - https://www.mongodb.com/docs/realm/realm-query-language/ 

Generated at Thu Feb 08 08:12:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.