Skip to content

Commit

Permalink
added .lean() on the report request + fixed the type error
Browse files Browse the repository at this point in the history
  • Loading branch information
sgempi committed Jul 5, 2024
1 parent 32d675d commit bf1dd9c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/retentionpolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ import Settings from './models/settings.js'
import User from './models/user.js'

async function getForRetentionPolicy(schema: schemaNames, date: Date, state: AnyState, startDate?: Date) {
let res
let res: Array<ITravel | IExpenseReport | IHealthCareCost>
if (startDate) {
res = await model(schema).find({ state: state, updatedAt: { $gte: startDate, $lt: date }, historic: false })
res = await model(schema)
.find({ state: state, updatedAt: { $gte: startDate, $lt: date }, historic: false })
.lean()
} else {
res = await model(schema).find({ state: state, updatedAt: { $lt: date }, historic: false })
res = await model(schema)
.find({ state: state, updatedAt: { $lt: date }, historic: false })
.lean()
}

return res
Expand Down

0 comments on commit bf1dd9c

Please sign in to comment.