add findByIdLean for workers

This commit is contained in:
Alex Holliday committed 2026-06-18 11:06:19 -07:00
1 parent f740eef0fa
commit 190a3b47da
2 files changed
+7

No files matched your search

@@ -22,6 +22,8 @@ export interface IMonitorsRepository {
createMonitors(monitors: Monitor[]): Promise<Monitor[]>;
// single fetch
findById(monitorId: string, teamId: string): Promise<Monitor>;
// for workers, don't need all details
findByIdLean(monitorId: string): Promise<Monitor | null>;
// collection fetch
findAll(): Promise<Monitor[] | null>;
@@ -38,6 +38,11 @@ class MongoMonitorsRepository implements IMonitorsRepository {
return this.toEntity(monitor);
};
findByIdLean = async (monitorId: string): Promise<Monitor | null> => {
const monitor = await MonitorModel.findOne({ _id: monitorId });
return monitor ? this.toEntity(monitor) : null;
};
findAll = async (): Promise<Monitor[]> => {
const monitors = await MonitorModel.find();
return this.mapDocuments(monitors);