import { Document, ObjectId, WithoutId, InferIdType, Filter, OptionalId, WithId, CountDocumentsOptions, DeleteOptions, FindOneAndDeleteOptions, FindOptions, BulkWriteOptions, FindOneAndUpdateOptions, UpdateOptions, FindOneAndReplaceOptions, CollationOptions, CreateCollectionOptions, MongoClient, CollectionOptions, Collection, UpdateFilter, FindCursor, UpdateResult } from 'mongodb'; import { ActionVisibility, Validators, Errors, Context } from 'moleculer'; import { ZodType, ZodObject } from 'zod/v4'; import { Y as ValidationSchema, J as JSONSchemaType, C as CustomActionSchema, P as PartialCustomServiceSchema } from '../types-Cdh7thEZ.cjs'; import { Readable } from 'stream'; import 'bson'; import 'ajv/dist/2019.js'; import 'pino'; import 'pino-pretty'; declare enum QueryOp { GT = "$gt", GTE = "$gte", LT = "$lt", LTE = "$lte", IN = "$in", EQ = "$eq", NE = "$ne" } type ActionGetParamsOptions = { allowFields?: boolean; }; type ActionCountParamsOptions = { queryType: 'object' | 'stringified'; }; type ActionListParamsOptions = { queryType: 'object' | 'stringified'; maxPageSize?: number; }; type ActionCreateParamsOptions = { allowClientId?: boolean; }; type ActionSchemaFactoryOptions = { schemaName?: string; schema?: S; timestamps: boolean; softDelete: boolean; tenantField: KeyString | false; }; interface ActionSchemaFactory { hasIdField(): boolean; hasTenantIdField(): boolean; /** * Function that make auto generated fields mandatory. */ createSchemaWithDbFields(): S; /** * Create the params for the find action. */ createFindParams(): S; /** * Create get AND getInternal action params. */ createGetParams(params: ActionGetParamsOptions): S; /** * Create count AND countInternal action params. */ createCountParams(params: ActionCountParamsOptions): S; /** * Create list action params. */ createListParams(params: ActionListParamsOptions): S; /** * Create list action result JSON schema. */ createListResponse(): S; /** * Create 'create' action params. */ createCreateParams(params: ActionCreateParamsOptions): S; /** * Create 'update' action params. */ createUpdateParams(): S; /** * Create 'remove' action params. */ createRemoveParams(): S; } /** * Utility type to extract the string keys of a type. */ type KeyString = Extract; type TenantParams | false> = (TenantField extends KeyString ? Pick : null) | null; type DatabaseMethodsOptions | false> = { /** * Name of the field that will be required to be present in all documents. * This will be used in read queries as a filter to ensure that the user * can only access documents that belong to the same tenant. * * This field can only be top-level and should probably be indexed. */ tenantField: TenantField; /** * Enable soft-delete for the model. * The remove method will only set the deletedAt field to NOW. * And a new `scope` field will be read to be able to read deleted documents. * * Note that if schema has a deletedAt field, you are required to set this option to true. */ softDelete: TSchema extends { deletedAt?: Date; } ? true : false; /** * Enable timestamps for the model. * Will automatically set the createdAt and updatedAt fields on write operations. * * Note that if schema has both createdAt and updatedAt field, you are required to set this option to true. */ timestamps: TSchema extends { createdAt?: Date; } ? TSchema extends { updatedAt?: Date; } ? true : false : false; /** * Note that this function will be applied ONLY on insert operations. */ idGenerator?: (doc: WithoutId) => InferIdType; /** * Prefix used for events. * If not specified, will disable events. * * Here is the list of events: * - `${eventPrefix}.created`: Sent on insertOne and insertMany * - `${eventPrefix}.updated`: Sent on updateOne and replaceOne * - `${eventPrefix}.deleted`: Sent on deleteOne */ eventPrefix?: string; /** * The sQuerySchema variable is an optional parameter used for validation. * This is used to parse the sQuery parameter on list and count actions. * If omitted, sQuery will be silently discarded. * It uses the same validator than on actions. * The schema will not be published on the openAPI. * See addQueryOps for easy support of some mongo operators. */ sQuerySchema?: ValidationSchema | ZodType; /** * Create the actions for the database mixin. * Read operations: * - find (max public) * - findStream (max public) * - getInternal (max public) * - get * - countInternal (max public) * - count * - list * * Write operations: * - create * - update * - remove * * If some actions are not provided here, it probably means that they are not necessary. * For example, there is no `findAllStream` or `updateMany` actions. This is because they are not used * often and is quite specific to the related service. */ actions?: DatabaseActionOptions; }; type DatabaseActionVisibility = T extends DatabaseActionInternalNames ? Exclude : ActionVisibility; type DatabaseActionOptions = { [key in DatabaseActionNames]?: { visibility: DatabaseActionVisibility; } & (key extends 'list' ? { maxPageSize?: number; defaultPageSize?: number; defaultSort?: string[]; } : NonNullable) & (key extends 'create' ? { allowClientId?: boolean; } : NonNullable); } & { schema?: JSONSchemaType | ZodObject; schemaFactory?: ActionSchemaFactory; schemaName?: string; }; type DatabaseActionInternalNames = 'find' | 'findStream' | 'getInternal' | 'countInternal'; type DatabaseActionPublishedNames = 'count' | 'list' | 'get' | 'create' | 'update' | 'remove'; type DatabaseActionNames = DatabaseActionInternalNames | DatabaseActionPublishedNames; /** * Create the actions for the database mixin. * Read operations: * - find (max public) * - findStream (max public) * - getInternal (max public) * - get * - countInternal (max public) * - count * - list * * Write operations: * - create * - update * - remove * * If some actions are not provided here, it probably means that they are not necessary. * For example, there is no `findAllStream` or `updateMany` actions. This is because they are not used * often and is quite specific to the related service. */ declare function createActions | false = false>(opts: DatabaseMethodsOptions): Partial>; declare class AjvActionSchemaFactory implements ActionSchemaFactory { private opts; private readonly tenantFieldType; private readonly _idFieldType; constructor(opts: ActionSchemaFactoryOptions, TSchema>); hasIdField(): boolean; hasTenantIdField(): boolean; createSchemaWithDbFields(): ValidationSchema; createFindParams(): ValidationSchema; createGetParams(params: ActionGetParamsOptions): ValidationSchema; createCountParams(params: ActionCountParamsOptions): ValidationSchema; createListParams(params: ActionListParamsOptions): ValidationSchema; createListResponse(): ValidationSchema; createCreateParams(params: ActionCreateParamsOptions): ValidationSchema; createUpdateParams(): ValidationSchema; createRemoveParams(): ValidationSchema; } declare function addQueryOps(schema: JSONSchemaType, queryOps: QueryOp[]): JSONSchemaType; declare function parseStringifiedQuery(sQuery?: string): Filter; declare function parseAndValidateQuery(validator: Validators.Base, schema: ValidationSchema | ZodType | undefined, sQuery: string | undefined): Filter; type DatabaseSoftDeleteScope = 'include-deleted' | 'only-deleted' | 'no-deleted'; /** * Options used on read only operations on the database mixin. * Wrapper around mongodb's FindOptions that is easier for us to use. */ type DatabaseFindOptions = Omit & { fields?: string[]; sort?: string[]; scope?: DatabaseSoftDeleteScope; strictTenantFilter?: boolean; }; /** * Options used on count operations on the database mixin. */ type DatabaseCountOptions = CountDocumentsOptions & { scope?: DatabaseSoftDeleteScope; strictTenantFilter?: boolean; }; /** * Options used on insertOne operations. * Wrapper around findOneAndUpdate options as we don't use insertOne directly but findOneAndUpdate with upsert. */ type DatabaseInsertOneOptions = Omit & { fields?: string[]; skipCreateEvent?: boolean; }; /** * Options used on insertMany operations. */ type DatabaseInsertManyOptions = BulkWriteOptions & { skipCreateEvent?: boolean; }; /** * Options used on updateOne operations. */ type DatabaseUpdateOneOptions = Omit & { fields?: string[]; sort?: string[]; strictTenantFilter?: boolean; skipUpdateEvent?: boolean; }; /** * Options used on updateMany operations. */ type DatabaseUpdateManyOptions = UpdateOptions & { strictTenantFilter?: boolean; }; /** * Options used on deleteOne operations. * If soft delete is enabled, the document will be updated with a deletedAt field. */ type DatabaseReplaceOneOptions = Omit & { fields?: string[]; sort?: string[]; strictTenantFilter?: boolean; skipUpdateEvent?: boolean; }; /** * Options used on deleteOne operations. * If soft delete is enabled, the document will be updated with a deletedAt field. */ type DatabaseDeleteOneOptions = Omit & { fields?: string[]; sort?: string[]; strictTenantFilter?: boolean; skipDeleteEvent?: boolean; }; /** * Options used on deleteMany operations. * If soft delete is enabled, the document will be updated with a deletedAt field. */ type DatabaseDeleteManyOptions = DeleteOptions & { strictTenantFilter?: boolean; }; /** * Type of the event sent by the database mixin on insert. * For insertMany, it will be sent once per document. */ type DatabaseEventInsert = { type: 'insert'; document: WithDbFields; }; /** * Type of the event sent by the database mixin on update. * No event is sent on updateMany. */ type DatabaseEventUpdate = { type: 'update' | 'replace'; document: WithDbFields; }; /** * Type of the event sent by the database mixin on update. * No event is sent on deleteMany. */ type DatabaseEventDelete = { type: 'delete'; document: WithDbFields; }; /** * Helper function that gives the type of document returned from the database. * It will add _id, createdAt and updatedAt fields if they are not already present. */ type WithDbFields = TSchema & WithId & (TSchema extends { createdAt?: Date; } ? TSchema extends { updatedAt?: Date; } ? { createdAt: Date; updatedAt: Date; } : NonNullable : NonNullable); type WithOptionalId = OptionalId; type DatabaseActionFindParams | false = false> = { query?: Filter; fields?: string[]; sort?: string[]; limit?: number; offset?: number; collation?: CollationOptions; } & (TSchema extends { deletedAt?: Date; } ? { scope?: DatabaseSoftDeleteScope; } : NonNullable) & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); type DatabaseActionFindResult = Array>; type DatabaseActionGetInternalParams | false = false> = { _id: InferIdType; fields?: string[]; } & (TSchema extends { deletedAt?: Date; } ? { scope?: DatabaseSoftDeleteScope; } : NonNullable) & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); type DatabaseActionEntityResult = WithDbFields; type DatabaseActionGetParams | false = false> = { _id: InferIdType; } & (TSchema extends { deletedAt?: Date; } ? { scope?: DatabaseSoftDeleteScope; } : NonNullable) & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); type DatabaseActionCountInternalParams | false = false> = { query?: Filter; } & (TSchema extends { deletedAt?: Date; } ? { scope?: DatabaseSoftDeleteScope; } : NonNullable) & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); type DatabaseActionCountParams | false = false> = { sQuery?: string; } & (TSchema extends { deletedAt?: Date; } ? { scope?: DatabaseSoftDeleteScope; } : NonNullable) & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); type DatabaseActionListParams | false = false> = { sQuery?: string; sort?: string[]; page?: number; pageSize?: number; collation?: CollationOptions; } & (TSchema extends { deletedAt?: Date; } ? { scope?: DatabaseSoftDeleteScope; } : NonNullable) & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); type DatabaseActionListResult = { rows: Array; page: number; pageSize: number; total: number; totalPages: number; }; type DatabaseActionCreateParams = WithOptionalId; type DatabaseActionUpdateParams | false = false> = Partial & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); type DatabaseActionRemoveParams | false = false> = { _id: InferIdType; } & (TenantField extends KeyString ? { [key in TenantField]: TSchema[TenantField]; } : NonNullable); declare class ZodActionSchemaFactory implements ActionSchemaFactory { private opts; private readonly tenantFieldType; private readonly _idFieldType; private schemaWithDbFields; constructor(opts: ActionSchemaFactoryOptions); hasIdField(): boolean; hasTenantIdField(): boolean; createSchemaWithDbFields(): ZodType; createFindParams(): ZodType; createGetParams(params: ActionGetParamsOptions): ZodType; createCountParams(params: ActionCountParamsOptions): ZodType; createListParams(params: ActionListParamsOptions): ZodType; createListResponse(): ZodType; createCreateParams(params: ActionCreateParamsOptions): ZodType; createUpdateParams(): ZodType; createRemoveParams(): ZodType; } declare function addZodQueryOps(fieldValue: ZodType, queryOps: QueryOp[]): ZodType; declare global { var __MONGO_URI__: string | undefined; var __MONGO_DB_NAME__: string | undefined; } type DatabaseConnectionOptions = { /** * Name of the database to use. * If not specified, will use the default one (inferred from uri). * * OVERRIDDEN by globalThis.__MONGO_DB_NAME__ if set, which is useful for tests. */ databaseName?: string; /** * Name of the collection in the DB. */ collectionName: string; /** * Collection creation options. * If not specified, will use the default one. * Note that it shouldn't be changed without being sure of what you are doing. */ createCollectionOptions?: CreateCollectionOptions; /** * URI of the MongoDB server. * If not specified, will try to use one from environment: * - process.env.MONGO_URL * - process.env.MONGODB_URL * - 'mongodb://localhost:27017' (default) * * OVERRIDDEN by globalThis.__MONGO_URI__ if set, which is useful for tests. */ uri?: string; }; declare function DatabaseConnectionMixin = never>(opts: DatabaseConnectionOptions): PartialCustomServiceSchema; }, PartialCustomServiceSchema; client: MongoClient; onClose: () => Promise | void; }>; getFromStore(storeName: string, key: string): MongoClient | null; removeServiceFromStore(storeName: string, key: string): Promise; setClientToStore(storeName: string, key: string, client: MongoClient, onClose: () => Promise | void): void; }, unknown>[]>; declare const MoleculerClientError: typeof Errors.MoleculerClientError; declare class EntityNotFoundError extends MoleculerClientError { constructor(id: string | string[]); } type MongoIndex = { key: Record; name?: string; expireAfterSeconds?: number; partialFilterExpression?: Record; sparse?: boolean; unique?: boolean; collation?: CollationOptions; }; type IndexTuple = [MongoIndex['key'], Omit?]; type SearchIndexCharFilter = { type: 'htmlStrip'; ignoredTags?: string[]; } | { type: 'icuNormalize'; } | { type: 'mapping'; mappings: Record; } | { type: 'persian'; }; type SearchIndexTokenizer = { type: 'edgeGram'; minGram: number; maxGram: number; } | { type: 'keyword'; } | { type: 'nGram'; minGram: number; maxGram: number; } | { type: 'regexCaptureGroup'; pattern: string; group: number; } | { type: 'regexSplit'; pattern: string; } | { type: 'standard'; maxTokenLength?: number; } | { type: 'uaxUrlEmail'; maxTokenLength?: number; } | { type: 'whitespace'; maxTokenLength?: number; }; type SearchIndexTokenFilter = { type: 'asciiFolding'; originalTokens?: 'include' | 'omit'; } | { type: 'daitchMokotoffSoundex'; originalTokens?: 'include' | 'omit'; } | { type: 'edgeGram'; minGram: number; maxGram: number; termNotInBounds?: 'include' | 'omit'; } | { type: 'englishPossessive'; } | { type: 'flattenGraph'; } | { type: 'icuFolding'; } | { type: 'icuNormalizer'; normalizationForm?: 'nfd' | 'nfc' | 'nfkd' | 'nfkc'; } | { type: 'kStemming'; } | { type: 'length'; min?: number; max?: number; } | { type: 'lowercase'; } | { type: 'nGram'; minGram: number; maxGram: number; termNotInBounds?: 'include' | 'omit'; } | { type: 'porterStemming'; } | { type: 'regex'; pattern: string; replacement: string; matches: 'all' | 'first'; } | { type: 'reverse'; } | { type: 'shingle'; minShingleSize: number; maxShingleSize: number; } | { type: 'snowballStemming'; stemmerName: string; } | { type: 'spanishPluralStemming'; } | { type: 'stempel'; } | { type: 'stopword'; tokens: string[]; ignoreCase?: boolean; } | { type: 'trim'; } | { type: 'wordDelimiterGraph'; delimiterOptions?: { generateWordParts?: boolean; generateNumberParts?: boolean; concatenateWords?: boolean; concatenateNumbers?: boolean; concatenateAll?: boolean; preserveOriginal?: boolean; splitOnCaseChange?: boolean; splitOnNumerics?: boolean; stemEnglishPossessive?: boolean; ignoreKeywords?: boolean; }; protectedWords?: { words: string[]; ignoreCase?: boolean; }; }; /** * Definition of a custom atlas search analyzer. * See https://www.mongodb.com/docs/atlas/atlas-search/analyzers/custom/#std-label-custom-analyzers */ type SearchIndexCustomAnalyzers = { name: string; charFilters?: Array; tokenizer: SearchIndexTokenizer; tokenFilters?: Array; }; type SearchIndexFieldString = { type: 'string'; analyzer?: string; searchAnalyzer?: string; indexOptions?: 'docs' | 'freqs' | 'positions' | 'offsets'; store?: boolean; ignoreAbove?: number; multi?: Record; norms?: 'include' | 'omit'; }; /** * Definition of a field in a search index. * See https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/ */ type SearchIndexField = { type: 'autocomplete'; analyzer?: string; maxGrams?: number; minGrams?: number; tokenization?: 'edgeGram' | 'rightEdgeGram' | 'nGram'; foldDiacritics?: boolean; } | { type: 'boolean'; } | { type: 'date'; } | { type: 'dateFacet'; } | { type: 'document'; dynamic?: boolean; fields?: Record; } | { type: 'embeddedDocuments'; dynamic?: boolean; fields?: Record; } | { type: 'geo'; indexShapes?: boolean; } | { type: 'number'; representation?: 'double' | 'int64'; indexIntegers?: boolean; indexDoubles?: boolean; } | { type: 'numberFacet'; representation?: 'double' | 'int64'; indexIntegers?: boolean; indexDoubles?: boolean; } | { type: 'objectId'; } | SearchIndexFieldString | { type: 'stringFacet'; } | { type: 'token'; normalizer?: 'lowercase' | 'none'; }; type SearchIndexDefinition = { analyzer?: string; searchAnalyzer?: string; mappings?: { dynamic?: boolean; fields?: Record; }; analyzers?: Array; storedSource?: boolean | { include: string[]; } | { exclude: string[]; }; synonyms?: Array<{ analyzer: string; name: string; source: { collection: string; }; }>; }; /** * Type of what is returned by listSearchIndexes. * See https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#output */ type ListSearchIndex = { id: string; name: string; status: 'BUILDING' | 'FAILED' | 'PENDING' | 'READY' | 'STALE'; queryable: boolean; latestDefinitionVersion: { version: number; createdAt: Date; }; latestDefinition: SearchIndexDefinition; statusDetail: Array<{ hostname: string; status: string; queryable: boolean; mainIndex: Document; stagedIndex: Document; }>; synonymMappingStatus: 'BUILDING' | 'FAILED' | 'READY'; synonymMappingStatusDetail: Array<{ status: string; queryable: boolean; }>; message: string; }; declare enum IndexStatus { OK = "OK", MISSING = "MISSING", OUTDATED = "OUTDATED", NOT_DECLARED = "NOT_DECLARED" } type IndexState = { type: 'index'; status: IndexStatus.OK | IndexStatus.OUTDATED; index: MongoIndex; declaredIndex: IndexTuple; } | { type: 'index'; status: IndexStatus.MISSING; declaredIndex: IndexTuple; } | { type: 'index'; status: IndexStatus.NOT_DECLARED; index: MongoIndex; } | { type: 'searchIndex'; status: IndexStatus.OK | IndexStatus.OUTDATED; name: string; searchIndex: SearchIndexDefinition; declaredSearchIndex: SearchIndexDefinition; } | { type: 'searchIndex'; status: IndexStatus.MISSING; name: string; declaredSearchIndex: SearchIndexDefinition; } | { type: 'searchIndex'; status: IndexStatus.NOT_DECLARED; name: string; searchIndex: SearchIndexDefinition; }; type DatabaseIndexesOptions = { indexes?: IndexTuple[]; searchIndexes?: Record; }; type SyncIndexesOptions = { createIndexes: boolean; dropIndexes: boolean; }; declare const DATABASE_INDEXES_MIXIN_SYNC_EVENT = "database-indexes-mixin.sync"; declare function DatabaseIndexesMixin(opts: DatabaseIndexesOptions): PartialCustomServiceSchema; _createIndexFromState(col: Collection, state: IndexState): Promise; }, unknown>; declare function getDefaultIndexName(key: Record): string; declare function isIndexNameEqual(dbIdx: MongoIndex, idx: IndexTuple): boolean; declare function isIndexEqual(dbIdx: MongoIndex, idx: IndexTuple): boolean; declare function isOnAtlas(): boolean; /** * Rule for auto synchronise indexes is, in that order to not be hosted in MongoDB Atlas * 1. check for specific operation env variable * 2. check for force operation env variable * 3. check if we're hosted on MongoDB Atlas * or to force sync with the SYNC_MONGO_INDEX = 'yes'. */ declare function shouldAutoCreateIndexes(): boolean; declare function shouldAutoDropIndexes(): boolean; declare function getIndexesDifference({ collection, declaredIdxs, }: { collection: Collection; declaredIdxs: IndexTuple[]; }): Promise<{ idxsToCreate: MongoIndex[]; idxsToUpdate: MongoIndex[]; idxsToDelete: Required[]; synced: boolean; }>; declare function removeMongoId(schema: JSONSchemaType>, refName?: string): JSONSchemaType>; declare function optionalMongoId(schema: JSONSchemaType>, refName?: string): JSONSchemaType>; /** * Optimize query index usage for $or queries. * This is particularly useful in case of partial indexes. * This distributes the original condition in all $or conditions. * @param query the query to optimize */ declare function optimizeQuery>(query: Filter): Filter; /** * Return an object with each list item as key and 1/0/-1 as value * to be used in mongo projection or sort. */ declare function getQueryFromList(type: T, list?: string[]): Record | undefined; declare function DatabaseMethodsMixin | false = false>(opts: DatabaseMethodsOptions): PartialCustomServiceSchema): void; /** * This method will automatically set the needed operators for our features (timestamps). * * Limitations of this method: * - Dates are generated on the mongo server, except for `update` type with upsert. * - It doesn't support $replaceWith/$replaceRoot in an aggregation pipeline except when using type `replace`. * - Replaces (`replace` type) can only be done with an aggregation pipeline with a single $replaceWith stage. * - Update aggregation pipelines will be modified to let the createdAt field stay the same. */ _prepareUpdateFilter(changes: UpdateFilter, type: "create" | "update" | "replace"): UpdateFilter; /** * Will get the tenant filter from params. * This filter should be used in all read queries to ensure that the user * can only access documents that belong to the same tenant. */ _getTenantFilter(params: TenantParams, strict?: boolean): Filter; /** * Will get the soft delete filter from params. * This filter should be used in all read queries. * * Indexes should also index the deleted field to ensure optimal performance. * Note that in order to support partial indexes, a non deleted field is checked * for `false` and `null` values. */ _getSoftDeleteFilter(scope?: DatabaseSoftDeleteScope): Filter; /** * Get a query filter optimized ($or problem) with additional filters applied: * - Tenant filter * - Soft delete filter */ _getQueryFilter(query: Filter, params: TenantParams, scope?: DatabaseSoftDeleteScope, strictTenantFilter?: boolean): Filter; /** * INTERNAL, DO NOT USE. * Simple wrapper around the DatabaseConnectionMixin.getCollection method to have typed collection. */ _getDatabaseMixinCollection(options?: CollectionOptions): Collection; /** * Create a find cursor with database mixin options applied. */ _createFindCursor(query: Filter, params: TenantParams, options?: DatabaseFindOptions): FindCursor>; _findOne(query: Filter, params: TenantParams, options?: Omit): Promise | null>; _find(query: Filter, params: TenantParams, options?: DatabaseFindOptions): Promise[]>; _findStream(query: Filter, params: TenantParams, options?: DatabaseFindOptions): Readable; _countDocuments(query: Filter, params: TenantParams, options?: DatabaseCountOptions): Promise; /** * Insert one document and return it. * * It differs from the driver's insertOne as it returns the inserted document and * send an event with the new document. */ _insertOne(ctx: Context, doc: OptionalId, options?: DatabaseInsertOneOptions): Promise>; /** * Insert many documents and return the list of inserted ids in the same order. */ _insertMany(ctx: Context, docs: OptionalId[], options?: DatabaseInsertManyOptions): Promise; /** * Update one document and return the after version by default. * To have the before version, use the `returnDocument` option. * * WARNING: Only send an event if returnDocument is 'after'.If returnDocument is 'before', * you MUST pass skipUpdateEvent: true and optionally send the event yourself. */ _updateOne(ctx: Context, query: Filter, params: TenantParams, changes: UpdateFilter, options?: DatabaseUpdateOneOptions): Promise | null>; /** * Update many documents and return the number of updated documents. * * WARNING: Do not send any events. You'll have to send an event yourself. */ _updateMany(query: Filter, params: TenantParams, changes: UpdateFilter, options?: DatabaseUpdateManyOptions): Promise>; /** * Replace one document and return the after version by default. * To have the before version, use the `returnDocument` option. * * WARNING: Only send an event if returnDocument is 'after'.If returnDocument is 'before', * you MUST pass skipUpdateEvent: true and optionally send the event yourself. */ _replaceOne(ctx: Context, query: Filter, params: TenantParams, doc: TSchema, options?: DatabaseReplaceOneOptions): Promise | null>; /** * Delete one document and return it. * If soft delete is enabled, it will only set the deleted field to true (hiding it from future requests). */ _deleteOne(ctx: Context, query: Filter, params: TenantParams, options?: DatabaseDeleteOneOptions): Promise | null>; /** * Delete many documents and return the number of deleted documents. * If soft delete is enabled, it will only set the deleted field to true (hiding it from future requests). * * WARNING: Do not send any events. You'll have to send an event yourself. */ _deleteMany(query: Filter, params: TenantParams, options?: DatabaseDeleteManyOptions): Promise; }, unknown>; export { AjvActionSchemaFactory, DATABASE_INDEXES_MIXIN_SYNC_EVENT, DatabaseConnectionMixin, DatabaseIndexesMixin, DatabaseMethodsMixin, EntityNotFoundError, IndexStatus, QueryOp, ZodActionSchemaFactory, addQueryOps, addZodQueryOps, createActions, getDefaultIndexName, getIndexesDifference, getQueryFromList, isIndexEqual, isIndexNameEqual, isOnAtlas, optimizeQuery, optionalMongoId, parseAndValidateQuery, parseStringifiedQuery, removeMongoId, shouldAutoCreateIndexes, shouldAutoDropIndexes }; export type { ActionCountParamsOptions, ActionCreateParamsOptions, ActionGetParamsOptions, ActionListParamsOptions, ActionSchemaFactory, ActionSchemaFactoryOptions, DatabaseActionCountInternalParams, DatabaseActionCountParams, DatabaseActionCreateParams, DatabaseActionEntityResult, DatabaseActionFindParams, DatabaseActionFindResult, DatabaseActionGetInternalParams, DatabaseActionGetParams, DatabaseActionInternalNames, DatabaseActionListParams, DatabaseActionListResult, DatabaseActionNames, DatabaseActionOptions, DatabaseActionPublishedNames, DatabaseActionRemoveParams, DatabaseActionUpdateParams, DatabaseConnectionOptions, DatabaseCountOptions, DatabaseDeleteManyOptions, DatabaseDeleteOneOptions, DatabaseEventDelete, DatabaseEventInsert, DatabaseEventUpdate, DatabaseFindOptions, DatabaseIndexesOptions, DatabaseInsertManyOptions, DatabaseInsertOneOptions, DatabaseMethodsOptions, DatabaseReplaceOneOptions, DatabaseSoftDeleteScope, DatabaseUpdateManyOptions, DatabaseUpdateOneOptions, IndexState, IndexTuple, KeyString, ListSearchIndex, MongoIndex, SearchIndexCustomAnalyzers, SearchIndexDefinition, SearchIndexField, SearchIndexFieldString, SyncIndexesOptions, TenantParams, WithDbFields, WithOptionalId };