add findByIdLean for workers
This commit is contained in:
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[]>;
|
createMonitors(monitors: Monitor[]): Promise<Monitor[]>;
|
||||||
// single fetch
|
// single fetch
|
||||||
findById(monitorId: string, teamId: string): Promise<Monitor>;
|
findById(monitorId: string, teamId: string): Promise<Monitor>;
|
||||||
|
// for workers, don't need all details
|
||||||
|
findByIdLean(monitorId: string): Promise<Monitor | null>;
|
||||||
|
|
||||||
// collection fetch
|
// collection fetch
|
||||||
findAll(): Promise<Monitor[] | null>;
|
findAll(): Promise<Monitor[] | null>;
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ class MongoMonitorsRepository implements IMonitorsRepository {
|
|||||||
return this.toEntity(monitor);
|
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[]> => {
|
findAll = async (): Promise<Monitor[]> => {
|
||||||
const monitors = await MonitorModel.find();
|
const monitors = await MonitorModel.find();
|
||||||
return this.mapDocuments(monitors);
|
return this.mapDocuments(monitors);
|
||||||
|
|||||||
Reference in new issue
Block a user