feat(cursor): Add toArray method to SmartdataDbCursor to convert raw MongoDB documents into initialized class instances
This commit is contained in:
@ -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.'
|
||||
}
|
||||
|
@ -40,6 +40,11 @@ export class SmartdataDbCursor<T = any> {
|
||||
}
|
||||
}
|
||||
|
||||
public async toArray() {
|
||||
const result = await this.mongodbCursor.toArray();
|
||||
return result.map((itemArg) => this.smartdataDbDoc.createInstanceFromMongoDbNativeDoc(itemArg));
|
||||
}
|
||||
|
||||
public async close() {
|
||||
await this.mongodbCursor.close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user