Skip to content

Commit ced8321

Browse files
committed
Merge branch 'main' of https://github.com/denodrivers/deno_mongo into bugfix-bad-types-for-push
2 parents 0a4f124 + 2cf47a7 commit ced8321

5 files changed

Lines changed: 7 additions & 6 deletions

File tree

deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from "https://deno.land/x/web_bson@v0.2.5/mod.ts";
1+
export * from "https://deno.land/x/web_bson@v0.3.0/mod.js";
22
export { crypto } from "https://deno.land/std@0.154.0/crypto/mod.ts";
33
export { BufReader } from "https://deno.land/std@0.154.0/io/mod.ts";
44
export { writeAll } from "https://deno.land/std@0.154.0/streams/conversion.ts";

src/collection/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { FindCursor } from "./commands/find.ts";
2727
import { ListIndexesCursor } from "./commands/list_indexes.ts";
2828
import { update } from "./commands/update.ts";
2929

30-
export class Collection<T> {
30+
export class Collection<T extends Document> {
3131
#protocol: WireProtocol;
3232
#dbName: string;
3333

src/database.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Database {
3838
});
3939
}
4040

41-
collection<T = Document>(name: string): Collection<T> {
41+
collection<T extends Document = Document>(name: string): Collection<T> {
4242
return new Collection<T>(this.#cluster.protocol, this.name, name);
4343
}
4444

@@ -88,7 +88,7 @@ export class Database {
8888
*
8989
* https://www.mongodb.com/docs/manual/reference/command/create/#mongodb-dbcommand-dbcmd.create
9090
*/
91-
async createCollection<T>(
91+
async createCollection<T extends Document>(
9292
name: string,
9393
options?: CreateCollectionOptions,
9494
): Promise<Collection<T>> {

src/gridfs/indexes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Collection } from "../collection/collection.ts";
22
import { Chunk, File } from "../types/gridfs.ts";
33
import { IndexOptions } from "../types.ts";
4+
import { Document } from "../../deps.ts";
45

5-
async function ensureIndex<T>(
6+
async function ensureIndex<T extends Document>(
67
index: IndexOptions,
78
collection: Collection<T>,
89
): Promise<ReturnType<Collection<T>["createIndexes"]>> {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ type Flatten<T> = T extends Array<infer Item> ? Item : T;
794794

795795
type IsAny<T, Y, N> = 0 extends (1 & T) ? Y : N;
796796

797-
export type InsertDocument<TDocument extends { _id?: ObjectId }> =
797+
export type InsertDocument<TDocument extends Document> =
798798
& Omit<TDocument, "_id">
799799
& {
800800
_id?: TDocument["_id"] | ObjectId;

0 commit comments

Comments
 (0)