You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
give me the latest version of a document for each distinct document theme
give the number of cats each persons possess and order them by that number.
Solution: virtual attributes
A virtual attribute is a specially named attribute that represent a computed value and can be used as any other attribute in query (for both conditions and scope)
A virtual attribute can only return a single value.
The $count virtual attribute
Gives the number of values hold by an attribute. If the attribute is sigle value, gives 1 if the value exists, 0 otherwise.
Syntax: $count(attribute)
The range selection virtual attribute
For a set of objets, objects are grouped by a set of attributes then for each group ordered inside it.
Syntax:
$isLast(attribute ordering) / group by attribute: true if it's the last value in the ordered set of objects optionally grouped by a set of attributes
$isFirst(attribute ordering) / group by attribute: true if it's the first value in the ordered set of objects optionally grouped by a set of attributes
- this is a massive commit, that will have an impact on #19, #16, #17, #8 and #20
- a ton of tests will be added very soon as this new implementation is much prone to state errors
Goal: being able to answer to:
Solution: virtual attributes
A virtual attribute is a specially named attribute that represent a computed value and can be used as any other attribute in query (for both conditions and scope)
A virtual attribute can only return a single value.
The $count virtual attribute
Gives the number of values hold by an attribute. If the attribute is sigle value, gives 1 if the value exists, 0 otherwise.
Syntax:
$count(attribute)
The range selection virtual attribute
For a set of objets, objects are grouped by a set of attributes then for each group ordered inside it.
Syntax:
$isLast(attribute ordering) / group by attribute
: true if it's the last value in the ordered set of objects optionally grouped by a set of attributes$isFirst(attribute ordering) / group by attribute
: true if it's the first value in the ordered set of objects optionally grouped by a set of attributesExamples:
{ $instanceOf: "Person", "$count(_cats)": { $gte: 3 } }
{ $instanceOf: "Document", "$isLast(+_date) / _theme": true }
{ scope: ["+$count(_cats)"] }
The text was updated successfully, but these errors were encountered: