airqo-platform / airqo-platform/AirQo-api
Replace deprecated findOneAndRemove with findOneAndDelete in SearchHistory model
- Lingua principale
- JavaScript
- Stelle
- 26
- Fork
- 24
- Merge medio
- 5h 36m
- PR unite (30g)
- 81
Descrizione
## Description
The `findOneAndRemove` method is deprecated in MongoDB/Mongoose and should be replaced with `findOneAndDelete` for better compatibility and to avoid using deprecated functions.
## Location
- **File**: `src/auth-service/models/SearchHistory.js`
- **Lines**: Around 184-187
- **Method**: `remove` static method in `SearchHistorySchema.statics`
## Current Code
```javascript
const removedSearchHistory = await this.findOneAndRemove(
filter,
options
).exec();
```
## Proposed Change
```javascript
const removedSearchHistory = await this.findOneAndDelete(
filter,
options
).exec();
```
## Context
This issue was identified during code review of the error handling improvements in the auth-service models.
## References
- **PR**: https://github.com/airqo-platform/AirQo-api/pull/4844
- **Comment**: https://github.com/airqo-platform/AirQo-api/pull/4844#discussion_r2124287027
- **Requester**: @Baalmart
## Priority
Low - Technical debt cleanup, no functional impact but improves code maintainability.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.