@spytecgps/nova-orm 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,6 +40,15 @@ export const getDevices = async (novaDataSource, params, logger) => {
|
|
|
40
40
|
if (params.projectionOptions.withClientDeviceSettings) {
|
|
41
41
|
queryBuilder = queryBuilder.leftJoinAndMapOne('device.clientDeviceSetting', ClientDeviceSetting, 'clientDeviceSetting', 'device.imei = clientDeviceSetting.imei and device.clientId = clientDeviceSetting.clientId');
|
|
42
42
|
}
|
|
43
|
+
if (params?.sortOptions?.sortField) {
|
|
44
|
+
queryBuilder = queryBuilder.orderBy(`device.${params.sortOptions.sortField}`, params?.sortOptions?.sortOrder ?? 'ASC');
|
|
45
|
+
}
|
|
46
|
+
if (params?.pagingOptions?.pageIndex) {
|
|
47
|
+
const pageSize = params?.pagingOptions?.pageSize ?? 1000;
|
|
48
|
+
const realPageIndex = (params?.pagingOptions?.pageIndex ?? 1) - 1;
|
|
49
|
+
queryBuilder = queryBuilder.offset(realPageIndex * pageSize);
|
|
50
|
+
queryBuilder = queryBuilder.limit(pageSize);
|
|
51
|
+
}
|
|
43
52
|
const devices = await queryBuilder.getMany();
|
|
44
53
|
return devices;
|
|
45
54
|
}, 'DevicesRepository::getDevices');
|
package/dist/types/common.d.ts
CHANGED
package/dist/types/devices.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionalReportPagination } from './common';
|
|
1
2
|
import { DeviceStatus } from './enums';
|
|
2
3
|
export interface GetDeviceParams {
|
|
3
4
|
filters: {
|
|
@@ -10,7 +11,7 @@ export interface GetDeviceParams {
|
|
|
10
11
|
withClientDeviceSettings: boolean;
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
export interface GetDevicesParams {
|
|
14
|
+
export interface GetDevicesParams extends OptionalReportPagination {
|
|
14
15
|
filters: {
|
|
15
16
|
deviceTypeId?: number;
|
|
16
17
|
status?: DeviceStatus;
|
|
@@ -18,9 +19,13 @@ export interface GetDevicesParams {
|
|
|
18
19
|
imeiList?: string[];
|
|
19
20
|
};
|
|
20
21
|
projectionOptions: {
|
|
21
|
-
withDeviceType
|
|
22
|
-
withIccidCarrier
|
|
23
|
-
withClientDeviceSettings
|
|
22
|
+
withDeviceType?: boolean;
|
|
23
|
+
withIccidCarrier?: boolean;
|
|
24
|
+
withClientDeviceSettings?: boolean;
|
|
25
|
+
};
|
|
26
|
+
sortOptions?: {
|
|
27
|
+
sortField?: 'name';
|
|
28
|
+
sortOrder?: 'ASC' | 'DESC';
|
|
24
29
|
};
|
|
25
30
|
}
|
|
26
31
|
export interface AllImeisAreActiveForClientParams {
|