Skip to content

Commit 8569aba

Browse files
committed
Collection: add type-level tests for index functions
1 parent bdba636 commit 8569aba

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/effect-mongodb/dtslint/Collection.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,33 @@ Collection.drop(collection)
144144

145145
// $ExpectType Effect<boolean, MongoError, never>
146146
F.pipe(collection, Collection.drop())
147+
148+
// -------------------------------------------------------------------------------------
149+
// createIndexes
150+
// -------------------------------------------------------------------------------------
151+
152+
// $ExpectType Effect<string[], MongoError, never>
153+
Collection.createIndexes(collection, [{ key: { birthday: 1 } }])
154+
155+
// $ExpectType Effect<string[], MongoError, never>
156+
F.pipe(collection, Collection.createIndexes([{ key: { birthday: 1 } }]))
157+
158+
// -------------------------------------------------------------------------------------
159+
// createIndex
160+
// -------------------------------------------------------------------------------------
161+
162+
// $ExpectType Effect<string, MongoError, never>
163+
Collection.createIndex(collection, { birthday: 1 })
164+
165+
// $ExpectType Effect<string, MongoError, never>
166+
F.pipe(collection, Collection.createIndex({ birthday: 1 }))
167+
168+
// -------------------------------------------------------------------------------------
169+
// dropIndex
170+
// -------------------------------------------------------------------------------------
171+
172+
// $ExpectType Effect<void, MongoError, never>
173+
Collection.dropIndex(collection, "birthday_1")
174+
175+
// $ExpectType Effect<void, MongoError, never>
176+
F.pipe(collection, Collection.dropIndex("birthday_1"))

packages/effect-mongodb/src/Collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ export const createIndex: {
407407
)
408408
)
409409

410+
// TODO: review return type. Should we return Document like mongodb driver?
410411
export const dropIndex: {
411412
(indexName: string, options?: DropIndexesOptions): <A extends Document, I extends Document, R>(
412413
collection: Collection<A, I, R>

0 commit comments

Comments
 (0)