(data: T)
| 716 | } |
| 717 | |
| 718 | private convertObjectIds<T extends ObjectId | Dictionary | string | any[]>(data: T): T { |
| 719 | if (data instanceof ObjectId) { |
| 720 | return data; |
| 721 | } |
| 722 | |
| 723 | if (typeof data === 'string' && /^[0-9a-f]{24}$/i.exec(data)) { |
| 724 | return new ObjectId(data) as T; |
| 725 | } |
| 726 | |
| 727 | if (Array.isArray(data)) { |
| 728 | return (data as T[]).map((item: any) => this.convertObjectIds(item)) as T; |
| 729 | } |
| 730 | |
| 731 | if (Utils.isObject(data)) { |
| 732 | Object.keys(data).forEach(k => { |
| 733 | data[k] = this.convertObjectIds(data[k]); |
| 734 | }); |
| 735 | } |
| 736 | |
| 737 | return data; |
| 738 | } |
| 739 | |
| 740 | private buildFilterById<T extends { _id: any }>(entityName: EntityName, id: string): FilterQuery<T> { |
| 741 | const meta = this.metadata.find(entityName)!; |
no test coverage detected