import mongoose from 'mongoose'; import { error } from '../../error.js'; import { MongoDbConfig, DbConfigsObj } from '../../types/core.types.js'; import { MongoDaoParsed, DaoMethodsMongo } from './types/mongoDbTypes.js'; import type { AllDbIds, DbIds } from '../../cache/dbs/index.generated.js'; import type { Definition } from '../../lib/good-cop//DefinitionClass.js'; declare global { interface GDeventNames extends NewEventType<'database.connected', []> { } } type ErrParams = Parameters; export type ModelAdditionalFields = { /** Will init a mongoose session and start a mongo transaction, the session is then stored in the ctx so all next DB calls are automatically using the transaction. So you'll have nothing to do except ending the transaction, which will trigger an admin alert if not closed for 30 seconds * * Make sure you await it */ startTransaction(ctx: Ctx): Promise; /** You have to call it after starting a transaction whenever the transaction is success or in a try / catch block to undo the transaction * * The endTransaction will take care of transactionCommit() or transactionAbort() depending on the status * * Make sure you await it */ endTransaction(ctx: Ctx, status: 'success'): Promise; endTransaction(ctx: Ctx, status: 'error', errMsg: ErrParams[0], errOptions: ErrParams[1]): Promise; endTransaction(ctx: Ctx, status: 'error', errMsg: false): Promise; mongooseConnection: mongoose.Connection; mongooseModels: { [modelNames: string]: mongoose.Model; }; }; export type ModelsConfigCache = any> = { [dbId: string]: { db: { [ModelName in keyof AllModels]: DaoMethodsMongo; } & ModelAdditionalFields; dbConfigs: MongoDbConfig; }; }; export declare function mongoInitDb(dbName: keyof DbIds, dbId: AllDbIds, modelsConfigCache: ModelsConfigCache, connectionConfig: Omit & { connexionString: string; }, daoConfigsParsed: { [k: string]: MongoDaoParsed; }, modelsGenerated: { [modelName: string]: Definition; }): Promise; export {};