Skip to content

Commit 8527caa

Browse files
committed
Collection: add type-level tests for aggregate
1 parent 8569aba commit 8527caa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/effect-mongodb/dtslint/Collection.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,19 @@ Collection.dropIndex(collection, "birthday_1")
174174

175175
// $ExpectType Effect<void, MongoError, never>
176176
F.pipe(collection, Collection.dropIndex("birthday_1"))
177+
178+
// -------------------------------------------------------------------------------------
179+
// aggregate
180+
// -------------------------------------------------------------------------------------
181+
182+
const MyAggregatedType = Schema.Struct({
183+
_id: Schema.Date,
184+
birthdays: Schema.Number
185+
})
186+
const groupByBirthday = [{ $group: { _id: "$birthday", birthdays: { $sum: 1 } } }]
187+
188+
// $ExpectType AggregationCursor<{ readonly _id: Date; readonly birthdays: number; }, { readonly _id: string; readonly birthdays: number; }, never>
189+
Collection.aggregate(collection, groupByBirthday, MyAggregatedType)
190+
191+
// $ExpectType AggregationCursor<{ readonly _id: Date; readonly birthdays: number; }, { readonly _id: string; readonly birthdays: number; }, never>
192+
F.pipe(collection, Collection.aggregate(groupByBirthday, MyAggregatedType))

0 commit comments

Comments
 (0)