feat(SmartDataDbDoc): Add extended cursor method getCursorExtended for flexible cursor modifications
This commit is contained in:
parent
24371ccf78
commit
ab251858ba
@ -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
|
||||
|
||||
|
@ -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.'
|
||||
}
|
||||
|
@ -249,6 +249,19 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public static async getCursorExtended<T>(
|
||||
this: plugins.tsclass.typeFest.Class<T>,
|
||||
filterArg: plugins.tsclass.typeFest.PartialDeep<T>,
|
||||
modifierFunction = (cursorArg: plugins.mongodb.FindCursor<plugins.mongodb.WithId<plugins.mongodb.BSON.Document>>) => cursorArg,
|
||||
) {
|
||||
const collection: SmartdataCollection<T> = (this as any).collection;
|
||||
let cursor: plugins.mongodb.FindCursor<any> = collection.mongoDbCollection.find(
|
||||
convertFilterForMongoDb(filterArg),
|
||||
);
|
||||
cursor = modifierFunction(cursor);
|
||||
return new SmartdataDbCursor<T>(cursor, this as any as typeof SmartDataDbDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* watch the collection
|
||||
* @param this
|
||||
|
Loading…
x
Reference in New Issue
Block a user