add updatebyids to monitor repository
This commit is contained in:
1 parent
d5dac6b557
commit
8c7b691fda
2 files changed
+7
No files matched your search
@@ -31,6 +31,7 @@ export interface IMonitorsRepository {
|
|||||||
|
|
||||||
// update
|
// update
|
||||||
updateById(monitorId: string, teamId: string, updates: Partial<Monitor>): Promise<Monitor>;
|
updateById(monitorId: string, teamId: string, updates: Partial<Monitor>): Promise<Monitor>;
|
||||||
|
updateByIds(monitorIds: string[], teamId: string, updates: Partial<Monitor>): Promise<number>;
|
||||||
updateStatusWindowAndChecks(
|
updateStatusWindowAndChecks(
|
||||||
monitorId: string,
|
monitorId: string,
|
||||||
teamId: string,
|
teamId: string,
|
||||||
|
|||||||
@@ -190,6 +190,12 @@ class MongoMonitorsRepository implements IMonitorsRepository {
|
|||||||
return this.toEntity(updatedMonitor);
|
return this.toEntity(updatedMonitor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateByIds = async (monitorIds: string[], teamId: string, updates: Partial<Monitor>) => {
|
||||||
|
const objectIds = monitorIds.map((id) => new mongoose.Types.ObjectId(id));
|
||||||
|
const updated = await MonitorModel.updateMany({ _id: { $in: objectIds }, teamId }, { $set: updates }, { runValidators: true });
|
||||||
|
return updated.modifiedCount;
|
||||||
|
};
|
||||||
|
|
||||||
updateStatusWindowAndChecks = async (
|
updateStatusWindowAndChecks = async (
|
||||||
monitorId: string,
|
monitorId: string,
|
||||||
teamId: string,
|
teamId: string,
|
||||||
|
|||||||
Reference in new issue
Block a user