import { DyFM_DataModel_Params, DyFM_DBFilter, DyFM_DBSort, DyFM_Metadata } from '@futdevpro/fsm-dynamo'; import { DyNTS_DBUpdate } from '../../_models/types/db-update.type'; import { DyNTS_DBQueryOptions } from '../../_models/interfaces/db-query-options.interface'; /** * DB Service for MongoDB */ export declare class DyNTS_DBService { dataParams: DyFM_DataModel_Params; serviceName: string; dataModel: any; private readonly depKeys; defaultErrorUserMsg: string; /** * @param dataName name the model * @param typeSample sample data for scheme creation (dont include DyFM_Metadata!) * @param schemaSettings additional settings for specific parameters as unique, required, minlength or maxlength * schemaSettings also MUST contain specific types that differs from the listed above (Array, Date) */ constructor(dataParams: DyFM_DataModel_Params); /** * save new data * @param data data * @returns data */ createData(data: T, issuer: string): Promise; /** * Find data by _id and update * @param data data * @returns data */ modifyData(data: T, issuer: string, dontUpdateModified?: boolean): Promise; /** * returns data by _id, * @param id id * @returns data */ getDataById(id: string): Promise; /** * get data by dependency data id, * !!!: throws error if not found (errorCode on not found: NTS-DBS-GD2) * * @param dependencyIdsFilter id * @returns data */ getDataByDependencyId(dependencyIdsFilter: { [key: string]: string; }): Promise; getDataListByIds(ids: string[], findDeleted?: boolean): Promise; /** * get data by dependency data id, * !!!: throws error if not found (errorCode on not found: NTS-DBS-GLD2) * * @param dependencyIdsFilter id * @returns dataList */ getDataListByDependencyId(dependencyIdsFilter: { [key: string]: string; }, findDeleted?: boolean): Promise; /** * get multiple data objects by a list of DependencyIDs, * !!!: throws error if not found (errorCode on not found: NTS-DBS-GLDS2) * * @param ids ids * @returns dataList */ getDataListByDependencyIds(dependencyKey: string, dependencyIds: string[], findDeleted?: boolean): Promise; /** * returns all data from database, * !!!: throws error if not found (errorCode on not found: NTS-DBS-GA1) * * @returns dataList */ getAll(findDeleted?: boolean): Promise; markDeletedById(id: string, issuer: string): Promise; markDeletedByDependencyId(dependencyIdsFilter: { [key: string]: string; }, issuer: string): Promise; restoreDeletedById(id: string, issuer: string): Promise; restoreDeletedByDependencyId(dependencyIdsFilter: { [key: string]: string; }, issuer: string): Promise; getDeletedDataList(): Promise; /** * deleted data by id * @param id id */ trueDeleteDataById(id: string): Promise; readonly deleteDataById: (id: string) => Promise; /** * deleted data by id * @param dependencyId id */ trueDeleteDataByDependencyId(dependencyIdsFilter: { [key: string]: string; }): Promise; readonly deleteDataByDependencyId: (dependencyIdsFilter: { [key: string]: string; }) => Promise; trueDeleteAllData(): Promise; readonly deleteAllData: () => Promise; /** * returns search result for searchBy object params * can use lists or xRange values for searchBy obj properties * * @param filterBy filter * @param narrowByDependencyIds id * @returns dataList */ searchData(filterBy: DyFM_DBFilter, narrowByDependencyIds?: string[], narrowByDependencyKey?: string, findDeleted?: boolean): Promise; /** * Find the data first by any of its parameters, * !!!: throws error if not found (errorCode on not found: NTS-DBS-FO1) * * @param filterBy if you can, use unique parameters for find! * * @example * // by email: * { email: email } * // * @example * // or by id that is in list: * { userIds: { $in: this.userId } } * // or by userIds: * { userId: { $in: userIds } } * // * @example * // or by number or Date that is Greater Than AND Less Than: * { points: { $gt: 2, $lt: 14 } } * // further tools (syntax matches with $gt): * $eq: // Matches values that are EQual to a specified value. * $gte: // Matches values that are Greater Than OR Equal to a specified value. * $lte: // Matches values that are Less Than or Equal to a specified value. * $ne: // Matches all values that are Not Equal to a specified value. * $nin: // Matches None of the values specified IN an array. * // * @returns {T} data: T */ findOne(filterBy: DyFM_DBFilter): Promise; /** * #MONGOOSE FUNCTION * Find the data first by any of its parameters, * !!!: throws error if not found (errorCode on not found: NTS-DBS-F1) * * @param filterBy if you can, use unique parameters for find! * * @example * // by email: * { email: email } * // * @example * // or by id that is in list: * { userIds: { $in: this.userId } } * // or by userIds: * { userId: { $in: userIds } } * // * @example * // or by number or Date that is Greater Than AND Less Than: * { points: { $gt: 2, $lt: 14 } } * // further tools (syntax matches with $gt): * $eq: // Matches values that are EQual to a specified value. * $gte: // Matches values that are Greater Than OR Equal to a specified value. * $lte: // Matches values that are Less Than or Equal to a specified value. * $ne: // Matches all values that are Not Equal to a specified value. * $nin: // Matches None of the values specified IN an array. * // * @param options BFR-008: opcionalis projection/limit/sort — DB-szinten szukit (a nagy mezok be sem toltodnek) * @returns {T[]} dataList: T[] */ find(filterBy: DyFM_DBFilter, findDeleted?: boolean, options?: DyNTS_DBQueryOptions): Promise; /** * #MONGOOSE FUNCTION * Find the data first by any of its parameters * WARNING: This function will not gives you back the total number of data in the database! * * @param filterBy if you can, use unique parameters for find! * * @example * // by email: * { email: email } * // * @example * // or by id that is in list: * { userIds: { $in: this.userId } } * // or by userIds: * { userId: { $in: userIds } } * // * @example * // or by number or Date that is Greater Than AND Less Than: * { points: { $gt: 2, $lt: 14 } } * // further tools (syntax matches with $gt): * $eq: // Matches values that are EQual to a specified value. * $gte: // Matches values that are Greater Than OR Equal to a specified value. * $lte: // Matches values that are Less Than or Equal to a specified value. * $ne: // Matches all values that are Not Equal to a specified value. * $nin: // Matches None of the values specified IN an array. * // * @param page page * @param pageSize pageSize * @param sort * @example * // by dateTime (this uses the basic sort function): * { dateTime: -1 } * // * @returns {T[]} dataList: T[] */ findWithPaging(filterBy: DyFM_DBFilter, page: number, pageSize: number, sort?: DyFM_DBSort): Promise; /** * #MONGOOSE FUNCTION * Find data by _id and update * * @param id id * @param update update * @returns data */ findByIdAndUpdate(id: string, update: DyNTS_DBUpdate, issuer: string, dontUpdateModified?: boolean): Promise; /** * #MONGOOSE FUNCTION * Atomi compare-and-set: filter-alapú find + update EGY műveletben, a MÓDOSÍTOTT dokumentum * visszaadásával (BFR-FDPTOKENSERVICE-006). * * A `findByIdAndUpdate` (id-only, nem filterezhető) és az `updateOne` (filterezhető, de void — * nem különíthető el a winner/loser konkurens state-átmenetnél) egyike sem elég CAS-hoz: egy * state-machine `transitionStatus`-jellegű átmenetnél a filter a FELTÉTEL (pl. `{_id, status: * 'locked'}`), és a visszatérő érték dönti el, hogy EZ a hívás nyerte-e az átmenetet. * `null` = nincs match (a feltétel már nem áll — a versenytárs nyert / state-collision). * * A `__lastModified`/`forbidModify` szemantika a `findByIdAndUpdate`-tel EGYEZŐ (egységes * update-viselkedés a base-ben); a `{ new: true }` a MÓDOSÍTOTT dokumentumot adja vissza. */ findOneAndUpdate(filterBy: DyFM_DBFilter, update: DyNTS_DBUpdate, issuer: string, dontUpdateModified?: boolean): Promise; /** * #MONGOOSE FUNCTION * Find the data first by any of its parameters * * @param filter This uses the basic Mongoose updateOne. * If you can, use unique parameters for find! * @example * // by email: * { email: email } * // * @example * // or by id that is in list: * { userIds: { $in: this.userId } } * // or by userIds: * { userId: { $in: userIds } } * // * @example * // or by number or Date that is Greater Than AND Less Than: * { points: { $gt: 2, $lt: 14 } } * // further tools (syntax matches with $gt): * $eq: // Matches values that are EQual to a specified value. * $gte: // Matches values that are Greater Than OR Equal to a specified value. * $lte: // Matches values that are Less Than or Equal to a specified value. * $ne: // Matches all values that are Not Equal to a specified value. * $nin: // Matches None of the values specified IN an array. * // * * @param update this uses the basic Mongoose updateOne * @example * // increase a specific value (here by 15): * { $inc: { popularity: 15 } } * // * @example * // or add element to a list: * { $push: { reactions: this.newReaction } * // or add multiple elements to a list * { $push: { schedule: {$each: [ monday, tuesday, wednesday ] } } } * // * @example * // or all at once * { * $inc: { popularity: this.newVote.amount }, * emailVerified: true, * $push: { reactions: this.newReaction } * } * // further tools (syntax matches with $inc): * $currentDate: // Sets the value of a field to current date, either as a Date or a Timestamp. * $min: // Only updates the field if the specified value is less than the existing field value. * $max: // Only updates the field if the specified value is greater than the existing field value. * $mul: // Multiplies the value of the field by the specified amount. * $rename: // Renames a field. * $unset: // Removes the specified field from a document. (set: "" to value) * // */ updateOne(filterBy: DyFM_DBFilter, update: DyNTS_DBUpdate, issuer: string, dontUpdateModified?: boolean): Promise; /** * #MONGOOSE FUNCTION * update one parameter by a specific * * @param filter This uses the basic Mongoose updateMany. * @example * // by email: * { email: email } * // * @example * // or by id that is in list: * { userIds: { $in: this.userId } } * // or by userIds: * { userId: { $in: userIds } } * // * @example * // or by number or Date that is Greater Than AND Less Than: * { points: { $gt: 2, $lt: 14 } } * // further tools (syntax matches with $gt): * $eq: // Matches values that are EQual to a specified value. * $gte: // Matches values that are Greater Than OR Equal to a specified value. * $lte: // Matches values that are Less Than or Equal to a specified value. * $ne: // Matches all values that are Not Equal to a specified value. * $nin: // Matches None of the values specified IN an array. * // * * @param update this uses the basic Mongoose updateOne * @example * // increase a specific value (here by 15): * { $inc: { popularity: 15 } } * // * @example * // or add element to a list: * { $push: { reactions: this.newReaction } * // or add multiple elements to a list * { $push: { schedule: {$each: [ monday, tuesday, wednesday ] } } } * // * @example * // or all at once * { * $inc: { popularity: this.newVote.amount }, * emailVerified: true, * $push: { reactions: this.newReaction } * } * // further tools (syntax matches with $inc): * $currentDate: // Sets the value of a field to current date, either as a Date or a Timestamp. * $min: // Only updates the field if the specified value is less than the existing field value. * $max: // Only updates the field if the specified value is greater than the existing field value. * $mul: // Multiplies the value of the field by the specified amount. * $rename: // Renames a field. * $unset: // Removes the specified field from a document. (set: "" to value) * // */ updateMany(filterBy: DyFM_DBFilter, update: DyNTS_DBUpdate, issuer: string, dontUpdateModified?: boolean): Promise; /** * { "mappings": { "dynamic": true, "fields": { "embedding": { "type": "knnVector", "dimensions": 768 } } } } */ /** * * @param set db.collection.aggregate([ { $vectorSearch: { index: "index_neve", queryVector: [a keresett embedding], path: "title.embedding", numCandidates: 100, limit: 5 } }, { $vectorSearch: { index: "index_neve", queryVector: [a keresett embedding], path: "description.embedding", numCandidates: 100, limit: 5 } } ]); * @returns */ aggregate(set: any): Promise; private stringifyDataId; private _getDefaultErrorSettings; /** * builds and returns mongoose schema * @returns schema */ private getSchema; /** * builds mongoose schema building settings object by dynamoDataModelParamsList * @param properties DynamoNTSDataPropertyParams * @returns mongoose schema object */ private buildMongooseSchemaSettingsObjByModelParams; private getBEType; /** * adds dynamo metadata settings to any mongoose schema building settings object * @param schema schema to update * @returns updated schema */ /** * adds dynamo metadata settings to any mongoose schema building settings object * @param properties properties to update * @returns updated properties */ private addMetadataToProperties; private addArchiveMetadataToProperties; /** * sets depDataKey */ private lookForDependencyDataSettings; private deleteThrowMethod; private modifyThrowMethod; } //# sourceMappingURL=db.service.d.ts.map