Skip to content

Commit

Permalink
include our own document type and re-export less
Browse files Browse the repository at this point in the history
Signed-off-by: Jersey <wgyt735yt@gmail.com>
  • Loading branch information
williamhorning committed Mar 23, 2024
1 parent 55b9ce4 commit a78a83b
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 35 deletions.
8 changes: 0 additions & 8 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@ export { MongoClient } from "./src/client.ts";
export { Database } from "./src/database.ts";
export { Collection } from "./src/collection/mod.ts";
export * from "./src/types.ts";
export * as Bson from "web-bson";
export type Document = Record<string, any>;
export {
Binary,
BSONRegExp,
BSONSymbol,
Code,
DBRef,
Decimal128,
Double,
Int32,
Long,
MaxKey,
MinKey,
ObjectId,
Timestamp,
UUID,
} from "web-bson";
export { GridFSBucket } from "./src/gridfs/bucket.ts";
3 changes: 1 addition & 2 deletions src/auth/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Document } from "../../mod.ts";
import { WireProtocol } from "../protocol/mod.ts";
import { ConnectOptions, Credential } from "../types.ts";
import { ConnectOptions, Credential, Document } from "../types.ts";

export abstract class AuthPlugin {
abstract prepare(authContext: AuthContext): Document;
Expand Down
4 changes: 2 additions & 2 deletions src/auth/scram.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { decodeBase64, encodeBase64 } from "b64";
import { encodeHex } from "hex";
import { crypto as stdCrypto } from "std_crypto";
import { Binary, Document } from "web-bson";
import { Binary } from "web-bson";
import { MongoDriverError } from "../error.ts";
import { HandshakeDocument } from "../protocol/handshake.ts";
import { driverMetadata } from "../protocol/mod.ts";
import { Credential } from "../types.ts";
import { Credential, Document } from "../types.ts";
import { saslprep } from "../utils/saslprep/mod.ts";
import { AuthContext, AuthPlugin } from "./base.ts";
import { pbkdf2 } from "./pbkdf2.ts";
Expand Down
3 changes: 1 addition & 2 deletions src/auth/x509.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Document } from "../../mod.ts";
import { HandshakeDocument } from "../protocol/handshake.ts";
import { driverMetadata } from "../protocol/mod.ts";
import { Credential } from "../types.ts";
import { Credential, Document } from "../types.ts";
import { AuthContext, AuthPlugin } from "./base.ts";

export interface X509Command extends Document {
Expand Down
8 changes: 6 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Document } from "../mod.ts";
import { Cluster } from "./cluster.ts";
import { Database } from "./database.ts";
import { MongoDriverError } from "./error.ts";
import { BuildInfo, ConnectOptions, ListDatabaseInfo } from "./types.ts";
import {
BuildInfo,
ConnectOptions,
Document,
ListDatabaseInfo,
} from "./types.ts";
import { parse } from "./utils/uri.ts";

export class MongoClient {
Expand Down
2 changes: 1 addition & 1 deletion src/collection/collection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ObjectId } from "web-bson";
import { Document } from "../../mod.ts";
import {
MongoDriverError,
MongoInvalidArgumentError,
Expand All @@ -13,6 +12,7 @@ import {
CreateIndexOptions,
DeleteOptions,
DistinctOptions,
Document,
DropIndexOptions,
DropOptions,
Filter,
Expand Down
3 changes: 1 addition & 2 deletions src/collection/commands/aggregate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Document } from "../../../mod.ts";
import { CommandCursor } from "../../protocol/cursor.ts";
import { WireProtocol } from "../../protocol/protocol.ts";
import { AggregateOptions } from "../../types.ts";
import { AggregateOptions, Document } from "../../types.ts";

interface AggregateCursorContext {
dbName: string;
Expand Down
3 changes: 1 addition & 2 deletions src/collection/commands/find.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Document } from "../../../mod.ts";
import { CommandCursor, WireProtocol } from "../../protocol/mod.ts";
import { FindOptions } from "../../types.ts";
import { Document, FindOptions } from "../../types.ts";

interface FindCursorContext {
dbName: string;
Expand Down
3 changes: 1 addition & 2 deletions src/collection/commands/update.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ObjectId } from "web-bson";
import { Document } from "../../../mod.ts";
import { WireProtocol } from "../../protocol/mod.ts";
import { UpdateOptions } from "../../types.ts";
import { Document, UpdateOptions } from "../../types.ts";

interface UpdateResponse {
ok: number;
Expand Down
7 changes: 5 additions & 2 deletions src/database.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Document } from "../mod.ts";
import { Cluster } from "./cluster.ts";
import { Collection } from "./collection/mod.ts";
import { CommandCursor } from "./protocol/mod.ts";
import { CreateCollectionOptions, CreateUserOptions } from "./types.ts";
import {
CreateCollectionOptions,
CreateUserOptions,
Document,
} from "./types.ts";
import { WriteConcern } from "./types/read_write_concern.ts";

interface ListCollectionsReponse {
Expand Down
3 changes: 1 addition & 2 deletions src/gridfs/indexes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Document } from "../../mod.ts";
import { Collection } from "../collection/collection.ts";
import { IndexOptions } from "../types.ts";
import { Document, IndexOptions } from "../types.ts";
import { Chunk, File } from "../types/gridfs.ts";

async function ensureIndex<T extends Document>(
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Long } from "web-bson";
import { Document } from "../../mod.ts";
import { Document } from "../types.ts";
import { parseNamespace } from "../utils/ns.ts";
import { WireProtocol } from "./protocol.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/protocol/handshake.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Document } from "../../mod.ts";
import { Document } from "../types.ts";
import { WireProtocol } from "./protocol.ts";

export const driverMetadata = {
Expand Down
3 changes: 2 additions & 1 deletion src/protocol/message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { deserialize, Document, serialize } from "web-bson";
import { deserialize, serialize } from "web-bson";
import { Document } from "../types.ts";
import { MessageHeader, OpCode, setHeader } from "./header.ts";

type MessageFlags = number;
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BufReader, writeAll } from "io";
import { Document } from "../../mod.ts";
import {
MongoDriverError,
MongoErrorInfo,
MongoServerError,
} from "../error.ts";
import { Document } from "../types.ts";
import { handshake } from "./handshake.ts";
import { parseHeader } from "./header.ts";
import { deserializeMessage, Message, serializeMessage } from "./message.ts";
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Binary,
BSONRegExp,
Decimal128,
Document,
Double,
Int32,
Long,
Expand Down Expand Up @@ -47,6 +46,8 @@ export interface CountOptions {
collation?: Document;
}

export type Document = Record<string, any>;

export interface FindOptions {
findOne?: boolean;
skip?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/types/geospatial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Document } from "../../mod.ts";
import { Document } from "../types.ts";
import {
GeoJsonObject,
GeometryCollection,
Expand Down
4 changes: 2 additions & 2 deletions src/types/gridfs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Binary, Document, ObjectId } from "web-bson";
import { ReadPreference } from "../types.ts";
import { Binary, ObjectId } from "web-bson";
import { Document, ReadPreference } from "../types.ts";
import { ReadConcern, WriteConcern } from "../types/read_write_concern.ts";

export type FileId = ObjectId;
Expand Down

0 comments on commit a78a83b

Please sign in to comment.