(conditions: FindObject<RawObject<T>>)
| 300 | } |
| 301 | |
| 302 | async find(conditions: FindObject<RawObject<T>>): Promise<T[]> { |
| 303 | const callId = uuid(); |
| 304 | |
| 305 | this.log.info({ callId, conditions }, '.find(conditions) called'); |
| 306 | |
| 307 | let results: T[]; |
| 308 | |
| 309 | try { |
| 310 | const documents = (await this.Model.find( |
| 311 | conditions == null ? {} : conditions |
| 312 | ) |
| 313 | .lean() |
| 314 | .exec()) as RawObject<T>[]; |
| 315 | |
| 316 | results = _.map(documents, (obj) => this.parse(obj)); |
| 317 | } catch (err) { |
| 318 | this.log.error( |
| 319 | { callId, conditions, err }, |
| 320 | '.find(conditions) thrown error!' |
| 321 | ); |
| 322 | throw err; |
| 323 | } |
| 324 | |
| 325 | this.log.info( |
| 326 | { callId, conditions, results }, |
| 327 | '.find(conditions) found results' |
| 328 | ); |
| 329 | |
| 330 | return results; |
| 331 | } |
| 332 | |
| 333 | async findOne(conditions: FindObject<RawObject<T>>): Promise<T> { |
| 334 | const callId = uuid(); |
no test coverage detected