From ab251858ba1146188afb990bdcc2771ef9c3dcf3 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 14 Apr 2025 17:49:07 +0000 Subject: [PATCH] feat(SmartDataDbDoc): Add extended cursor method getCursorExtended for flexible cursor modifications --- changelog.md | 7 +++++++ ts/00_commitinfo_data.ts | 2 +- ts/classes.doc.ts | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 67fb800..8a06738 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-04-14 - 5.7.0 - feat(SmartDataDbDoc) +Add extended cursor method getCursorExtended for flexible cursor modifications + +- Introduces getCursorExtended in classes.doc.ts to allow modifier functions for MongoDB cursors +- Wraps the modified cursor with SmartdataDbCursor for improved API consistency +- Enhances querying capabilities by enabling customized cursor transformations + ## 2025-04-07 - 5.6.0 - feat(indexing) Add support for regular index creation in documents and collections diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 041d8ff..2c2b036 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartdata', - version: '5.6.0', + version: '5.7.0', description: 'An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.' } diff --git a/ts/classes.doc.ts b/ts/classes.doc.ts index 5935e5e..9f048fe 100644 --- a/ts/classes.doc.ts +++ b/ts/classes.doc.ts @@ -249,6 +249,19 @@ export class SmartDataDbDoc( + this: plugins.tsclass.typeFest.Class, + filterArg: plugins.tsclass.typeFest.PartialDeep, + modifierFunction = (cursorArg: plugins.mongodb.FindCursor>) => cursorArg, + ) { + const collection: SmartdataCollection = (this as any).collection; + let cursor: plugins.mongodb.FindCursor = collection.mongoDbCollection.find( + convertFilterForMongoDb(filterArg), + ); + cursor = modifierFunction(cursor); + return new SmartdataDbCursor(cursor, this as any as typeof SmartDataDbDoc); + } + /** * watch the collection * @param this