Skip to content

Commit

Permalink
add FindOptions optional parameter to Collection.find and DocumentCol…
Browse files Browse the repository at this point in the history
…lection.find
  • Loading branch information
devmatteini committed Sep 20, 2024
1 parent 0fae968 commit 3e62e29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export class Collection<A extends Document, I extends Document = A, R = never> e
export type FindOptions = Omit<MongoFindOptions, "projection">

export const find = <A extends Document, I extends Document = A, R = never>(
collection: Collection<A, I, R>
collection: Collection<A, I, R>,
// TODO: should we omit keys available as Cursor functions?
options?: FindOptions
): FindCursor.FindCursor<A, I, R> =>
new FindCursor.FindCursor<A, I, R>(
{
cursor: collection.collection.find(),
cursor: collection.collection.find({}, options),
schema: collection.schema
}
)
Expand Down
6 changes: 4 additions & 2 deletions src/DocumentCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export class DocumentCollection extends Data.TaggedClass("DocumentCollection")<{
}

export const find = (
collection: DocumentCollection
collection: DocumentCollection,
// TODO: should we omit keys available as Cursor functions?
options?: FindOptions
): DocumentFindCursor.DocumentFindCursor =>
new DocumentFindCursor.DocumentFindCursor(
{
cursor: collection.collection.find()
cursor: collection.collection.find({}, options)
}
)

Expand Down

0 comments on commit 3e62e29

Please sign in to comment.