Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/model/src/main.ts>Model

model based mongo for deno
Latest
class Model
import { Model } from "https://deno.land/x/model@v1.2/src/main.ts";

Constructors

new
Model(
collectionName: string,
conn: string,
PopulateOptions?: PopulateOptions,
)
new
Model(
collectionName: string,
PopulateOptions?: PopulateOptions,
)
new
Model(
collectionName: string,
conn: { client: MongoClient; },
PopulateOptions?: PopulateOptions,
)
new
Model(
collectionName: string,
conn: { client: MongoClient; database: Database; },
PopulateOptions?: PopulateOptions,
)
new
Model(
collectionName: string,
conn: { client: MongoClient; database: string; },
PopulateOptions?: PopulateOptions,
)
new
Model(
collectionName: string,
conn: { ConnectionOptions: ConnectOptions; },
PopulateOptions?: PopulateOptions,
)
new
Model(
collectionName: string,
conn: { ConnectionOptions: ConnectOptions; database: string; },
PopulateOptions?: PopulateOptions,
)
new
Model(
collectionName: string,
conn: string | MongoClient | { client?: MongoClient; database?: Database | string; ConnectionOptions?: ConnectOptions; },
PopulateOptions?: PopulateOptions,
)

Type Parameters

Schema
optional
populateSchema extends PopulateSchema = Record<never, never>

Properties

private
optional
PopulateOptions: PopulateOptions
readonly
client: MongoClient
readonly
collectionName: string

Methods

connect(unnamed 0: { connection: string | ConnectOptions; database?: string; }): Promise<void>
count(filter: Filter<Schema>, options?: CountOptions)
delete(filter?: Filter<Schema>, options?: FindOptions & { multiple?: true; }): Promise<ObjectId[]>
delete(filter?: Filter<Schema>, options?: FindOptions & { multiple?: false; }): Promise<ObjectId | unknown>
insert(document: InsertDocument<Schema>, InsertOptions?: InsertOptions): Promise<ObjectId>
insert(document: InsertDocument<Schema>[], InsertOptions?: InsertOptions): Promise<ObjectId[]>
select<projection extends ProjectionType<Schema> | unknown, multiple extends boolean | unknown, populate extends
| true
| string
| string[]
| unknown
>
(filter?: Filter<Schema>, options?: Omit<FindOptions, "projection"> & { multiple?: multiple; populate?: populate; projection?: projection; }): Promise<SelectResult<projection, Schema, populateSchema, populate, multiple>>
update(
filter: Filter<Schema>,
document: Partial<Schema> & Bson.Document,
options?: FindOptions & { multiple?: true; },
): Promise<ObjectId[]>
update(
filter: Filter<Schema>,
document: Partial<Schema> & Bson.Document,
options?: FindOptions & { multiple?: false; },
): Promise<ObjectId | unknown>