@oridune/epic-odm
Advanced tools
Comparing version 1.1.10 to 1.1.11
{ | ||
"name": "@oridune/epic-odm", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "Install 1 ODM and code once with any database driver.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -149,27 +149,13 @@ "use strict"; | ||
} | ||
// public async exec<C extends DatabaseCommand<any, "create" | "find">>( | ||
// command: C, | ||
// options?: ExecutionOptions | ||
// ): Promise<Array<C["model"]["prototype"]>>; | ||
// public async exec<C extends DatabaseCommand<any, "createOne" | "findOne">>( | ||
// command: C, | ||
// options?: ExecutionOptions | ||
// ): Promise<C["model"]["prototype"] | undefined>; | ||
// public async exec<C extends DatabaseCommand<any, "update" | "save">>( | ||
// command: C, | ||
// options?: ExecutionOptions | ||
// ): Promise<{ updatedCount: number }>; | ||
// public async exec<C extends DatabaseCommand<any, "delete">>( | ||
// command: C, | ||
// options?: ExecutionOptions | ||
// ): Promise<{ deletedCount: number }>; | ||
async exec(command, options) { | ||
// Resolve Options | ||
const Options = Object.assign(Object.assign(Object.assign({}, command.aggregate.execOptions), command.execOptions), options); | ||
// Resolve Projection | ||
const Project = (options === null || options === void 0 ? void 0 : options.project) instanceof utils_2.ModelProjection | ||
? options.project | ||
: new utils_2.ModelProjection(command.model, (options === null || options === void 0 ? void 0 : options.project) || []); | ||
const Project = Options.project instanceof utils_2.ModelProjection | ||
? Options.project | ||
: new utils_2.ModelProjection(command.model, Options.project || []); | ||
// Resolve Funnel | ||
const Funnel = (options === null || options === void 0 ? void 0 : options.funnel) instanceof utils_2.ModelProjection | ||
? options.funnel | ||
: new utils_2.ModelProjection(command.model, (options === null || options === void 0 ? void 0 : options.funnel) || []); | ||
const Funnel = Options.funnel instanceof utils_2.ModelProjection | ||
? Options.funnel | ||
: new utils_2.ModelProjection(command.model, Options.funnel || []); | ||
const Results = (async () => { | ||
@@ -183,3 +169,3 @@ // Execute Command | ||
funnel: Funnel, | ||
strict: options === null || options === void 0 ? void 0 : options.strict, | ||
strict: Options.strict, | ||
}); | ||
@@ -191,3 +177,3 @@ case "createOne": | ||
funnel: Funnel, | ||
strict: options === null || options === void 0 ? void 0 : options.strict, | ||
strict: Options.strict, | ||
}))[0]; | ||
@@ -199,3 +185,3 @@ case "find": | ||
funnel: Funnel, | ||
strict: options === null || options === void 0 ? void 0 : options.strict, | ||
strict: Options.strict, | ||
}); | ||
@@ -207,3 +193,3 @@ case "findOne": | ||
funnel: Funnel, | ||
strict: options === null || options === void 0 ? void 0 : options.strict, | ||
strict: Options.strict, | ||
}))[0]; | ||
@@ -216,3 +202,3 @@ case "update": | ||
funnel: Funnel, | ||
strict: options === null || options === void 0 ? void 0 : options.strict, | ||
strict: Options.strict, | ||
}); | ||
@@ -224,3 +210,3 @@ case "delete": | ||
funnel: Funnel, | ||
strict: options === null || options === void 0 ? void 0 : options.strict, | ||
strict: Options.strict, | ||
}); | ||
@@ -227,0 +213,0 @@ default: |
@@ -8,2 +8,3 @@ import { BaseModel } from "./base"; | ||
import { MetaOptions } from "../decorators/meta"; | ||
import { ExecutionOptions } from "../database"; | ||
export declare type DatabaseCommandType = "create" | "createOne" | "find" | "findOne" | "update" | "save" | "delete"; | ||
@@ -18,2 +19,3 @@ export interface DatabaseCommand<M extends typeof BaseModel, T extends DatabaseCommandType, O = any> { | ||
deletes: typeof BaseModel[]; | ||
execOptions?: ExecutionOptions; | ||
} | ||
@@ -20,0 +22,0 @@ export declare class BaseModelStatic { |
import { Operator, TComparisonOperators, TRangeOperators, TMutationOperators, TCheckOperators, TOtherOperators, ValueType } from "../operators"; | ||
import { BaseModel } from "./base"; | ||
import { ExecutionOptions } from "../database"; | ||
export declare type ModelPayload<M extends BaseModel> = { | ||
@@ -32,2 +33,3 @@ [K in keyof M]?: M[K] extends Array<infer T> ? Array<T extends BaseModel ? ModelPayload<T> : T> : M[K] extends BaseModel ? ModelPayload<M[K]> : K extends "_id" ? M[K] | Operator<"ObjectID", M[K]> : M[K]; | ||
sort?: string | string[]; | ||
execOptions?: ExecutionOptions; | ||
} | ||
@@ -34,0 +36,0 @@ export declare class ModelProjection<M extends typeof BaseModel> { |
133586
2805