diff --git a/changelog.md b/changelog.md index 8a06738..63dea7f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2025-04-14 - 5.8.0 - feat(cursor) +Add toArray method to SmartdataDbCursor to convert raw MongoDB documents into initialized class instances + +- Introduced asynchronous toArray method in SmartdataDbCursor which retrieves all documents from the MongoDB cursor +- Maps each native document to a SmartDataDbDoc instance using createInstanceFromMongoDbNativeDoc for consistent API usage + ## 2025-04-14 - 5.7.0 - feat(SmartDataDbDoc) Add extended cursor method getCursorExtended for flexible cursor modifications diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 2c2b036..3aa7281 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.7.0', + version: '5.8.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.cursor.ts b/ts/classes.cursor.ts index 7882363..7719232 100644 --- a/ts/classes.cursor.ts +++ b/ts/classes.cursor.ts @@ -40,6 +40,11 @@ export class SmartdataDbCursor { } } + public async toArray() { + const result = await this.mongodbCursor.toArray(); + return result.map((itemArg) => this.smartdataDbDoc.createInstanceFromMongoDbNativeDoc(itemArg)); + } + public async close() { await this.mongodbCursor.close(); }