groups
The method allows to query collection groups. It’s available as an extension that you import separately:
import { groups } from "typesaurus";
await groups(db).comments.query(($) => $.field("rating").gt(3));//=> Array<Doc<ProductComment> | Doc<PostComment>>
The method accepts the database instance as the argument and returns a collections groups wrapper.
→ Read the collection group guide
API
All collections groups have altered methods available:
all
- reads all documents in the groupquery
- queries the groupcount
- counts all documents in the groupsum
- sums give document field values in the groupaverage
- calculates the average of given document field values in the group
Unlike the regular all
and query
, reading collection group will return mixed document types.