UNPKG

ottoman

Version:
78 lines (77 loc) 4.41 kB
import { DropCollectionOptions } from 'couchbase'; import { Model, Query } from '..'; import { FindOptions, ManyQueryResponse } from '../handler'; import { FindByIdOptions, IFindOptions } from '../handler/'; import { IConditionExpr, LogicalWhereExpr } from '../query'; import { CastOptions, MutationFunctionOptions } from '../utils/cast-strategy'; import { CreateModel } from './interfaces/create-model.interface'; import { FindOneAndUpdateOption } from './interfaces/find.interface'; import { ModelMetadata } from './interfaces/model-metadata.interface'; import { UpdateManyOptions } from './interfaces/update-many.interface'; import { ModelTypes, saveOptions, CountOptions, CountOptions as removeOptions } from './model.types'; /** * @ignore */ export declare const createModel: <T = any, R = any>({ name, schemaDraft, options, ottoman }: CreateModel) => ModelTypes<T, R>; export declare const _buildModel: (metadata: ModelMetadata) => { new <T>(data: any, options?: CastOptions): { [key: string]: any; "__#1@#isNew": boolean; readonly $: ModelMetadata; _getId(): string; _getIdField(): string; save(onlyCreate?: boolean, options?: saveOptions): Promise<any>; remove(options?: import("./model.types").removeOptions): Promise<any>; _populate(fieldsName?: import("./populate.types").PopulateFieldsType | undefined, options?: import("./populate.types").PopulateOptionsType | undefined): Promise<any>; _depopulate(fieldsName: string | string[]): any; _populated(fieldName: string): boolean; _applyData(data: any, strategy?: import("../utils/cast-strategy").ApplyStrategy): any; _validate(): any; toObject(): any; toJSON(): any; $toObject(): any; readonly $isNew: boolean; }; readonly namespace: string; readonly collectionName: string; query(params: IConditionExpr): Query; find: (filter?: LogicalWhereExpr, options?: IFindOptions) => Promise<any>; collection: any; /** * dropCollection drops a collection from a scope in a bucket. * @param collectionName * @param scopeName * @param options */ dropCollection(collectionName?: string, scopeName?: string, options?: DropCollectionOptions): Promise<boolean | undefined | void>; count: (filter?: LogicalWhereExpr, options?: CountOptions) => Promise<any>; findById: (id: string, options?: FindByIdOptions) => Promise<Model | Record<string, unknown>>; findOne: (filter?: LogicalWhereExpr, options?: FindOptions) => Promise<any>; create: (data: Record<string, any>, options?: saveOptions) => Promise<any>; createMany: (docs: Record<string, unknown>[] | Record<string, unknown>, options?: saveOptions) => Promise<ManyQueryResponse<any>>; updateById: (id: string, data: any, options?: MutationFunctionOptions) => Promise<any>; replaceById: (id: string, data: any, options?: MutationFunctionOptions) => Promise<any>; removeById: (id: string, options?: removeOptions) => Promise<any>; fromData(data: Record<string, any>): { [key: string]: any; "__#1@#isNew": boolean; readonly $: ModelMetadata; _getId(): string; _getIdField(): string; save(onlyCreate?: boolean, options?: saveOptions): Promise<any>; remove(options?: import("./model.types").removeOptions): Promise<any>; _populate(fieldsName?: import("./populate.types").PopulateFieldsType | undefined, options?: import("./populate.types").PopulateOptionsType | undefined): Promise<any>; _depopulate(fieldsName: string | string[]): any; _populated(fieldName: string): boolean; _applyData(data: any, strategy?: import("../utils/cast-strategy").ApplyStrategy): any; _validate(): any; toObject(): any; toJSON(): any; $toObject(): any; readonly $isNew: boolean; }; removeMany: (filter?: LogicalWhereExpr, options?: FindOptions) => Promise<ManyQueryResponse<any>>; updateMany: (filter: LogicalWhereExpr<any> | undefined, doc: Record<string, unknown>, options?: UpdateManyOptions) => Promise<ManyQueryResponse<any>>; findOneAndUpdate: (filter: LogicalWhereExpr<any> | undefined, doc: Record<string, unknown>, options?: FindOneAndUpdateOption) => Promise<any>; findOneAndRemove: (filter?: LogicalWhereExpr, options?: removeOptions) => Promise<any>; };