diff --git a/src/data/mongo/collections/device.test.ts b/src/data/mongo/collections/device.test.ts index 1e516ae15..5891eec94 100644 --- a/src/data/mongo/collections/device.test.ts +++ b/src/data/mongo/collections/device.test.ts @@ -64,13 +64,13 @@ describe('MongoDeviceTable', () => { expect(collection.findOne).toHaveBeenCalledWith({ guid: 'someId', tenantId: 'someTenantId' }) }) - it('should delete document by name and tenantId', async () => { + it('should delete document by guid and tenantId', async () => { collection.deleteOne.mockResolvedValue({ deletedCount: 1 } as any) - const result = await mongoDeviceTable.delete('someName', 'someTenantId') + const result = await mongoDeviceTable.delete('someGuid', 'someTenantId') expect(result).toBe(true) - expect(collection.deleteOne).toHaveBeenCalledWith({ friendlyName: 'someName', tenantId: 'someTenantId' }) + expect(collection.deleteOne).toHaveBeenCalledWith({ guid: 'someGuid', tenantId: 'someTenantId' }) }) it('should insert a device', async () => { diff --git a/src/data/mongo/collections/device.ts b/src/data/mongo/collections/device.ts index 8374fb2f4..40c3b3d26 100644 --- a/src/data/mongo/collections/device.ts +++ b/src/data/mongo/collections/device.ts @@ -33,8 +33,8 @@ export class MongoDeviceTable implements IDeviceTable { return this.collection.findOne({ guid: id, tenantId }) as unknown as WithId } - async delete (name: string, tenantId: string = ''): Promise { - const result = await this.collection.deleteOne({ friendlyName: name, tenantId }) + async delete (id: string, tenantId: string = ''): Promise { + const result = await this.collection.deleteOne({ guid: id, tenantId }) return result.deletedCount && result.deletedCount > 0 }