Skip to content

Commit

Permalink
refactor(db): align variable names for limit and offset
Browse files Browse the repository at this point in the history
This is not a breaking change despite the variable names changing in the interface/implementation as typescript
doesn't enforce the parameter names.
  • Loading branch information
rsdmike committed Sep 14, 2023
1 parent b3bed90 commit ce3c9da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/data/postgres/tables/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class DeviceTable implements IDeviceTable {
* @description Get all devices from DB
* @returns {Device[]} returns an array of objects
*/
async get (top: number = DefaultTop, skip: number = DefaultSkip, tenantId: string = ''): Promise<Device[]> {
async get (limit: number = DefaultTop, offset: number = DefaultSkip, tenantId: string = ''): Promise<Device[]> {
const results = await this.db.query<Device>(`
SELECT
guid as "guid",
Expand All @@ -47,7 +47,7 @@ export class DeviceTable implements IDeviceTable {
FROM devices
WHERE tenantid = $3
ORDER BY guid
LIMIT $1 OFFSET $2`, [top, skip, tenantId])
LIMIT $1 OFFSET $2`, [limit, offset, tenantId])
return results.rows
}

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IDeviceTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { type ITable } from './ITable'
export interface IDeviceTable extends ITable<Device> {
getConnectedDevices: (tenantId?: string) => Promise<number>
getDistinctTags: (tenantId?: string) => Promise<string[]>
getByTags: (tags: string[], method: string, top: number, skip: number, tenantId?: string) => Promise<Device[]>
getByTags: (tags: string[], method: string, limit: number | string, offset: number | string, tenantId?: string) => Promise<Device[]>
getByFriendlyName: (hostname: string, tenantId?: string) => Promise<Device[]>
getByHostname: (hostname: string, tenantId?: string) => Promise<Device[]>
clearInstanceStatus: (mpsInstance: string, tenantId?: string) => Promise<boolean>
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ITable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

export interface ITable<T> {
getCount: (tenantId?: string) => Promise<number>
get: (limit: number, offset: number, tenantId?: string) => Promise<T[]>
get: (limit: number | string, offset: number | string, tenantId?: string) => Promise<T[]>
getById: (id: string, tenantId?: string) => Promise<T>
delete: (name: string, tenantId?: string) => Promise<boolean>
insert: (item: T) => Promise<T>
Expand Down

0 comments on commit ce3c9da

Please sign in to comment.