Skip to content

Commit d4fe9e8

Browse files
committed
fix: remove filter query manual
1 parent c288579 commit d4fe9e8

File tree

2 files changed

+1
-39
lines changed

2 files changed

+1
-39
lines changed

src/helpers/Common.ts

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-unused-vars */
22
import fs from 'fs'
33
import db from 'models/_instance'
4-
import { FilterAttributes } from 'models'
54

65
const { Sequelize } = db
76
const { Op } = Sequelize
@@ -19,26 +18,6 @@ function getUniqueCodev2(length = 32) {
1918
return result
2019
}
2120

22-
// Filter Query Object
23-
function filterQueryObject(filtered: FilterAttributes[]) {
24-
const resultObject = {}
25-
if (typeof filtered !== 'object') {
26-
throw new Error(`Filtered must be an object, expected ${typeof filtered}`)
27-
}
28-
29-
for (let i = 0; i < filtered.length; i += 1) {
30-
// eslint-disable-next-line prefer-const
31-
let { id, value } = filtered[i]
32-
if (id.split('.').length > 1) {
33-
id = `$${id}$`
34-
}
35-
// @ts-ignore
36-
resultObject[id] = { [Op.like]: `%${value}%` }
37-
}
38-
39-
return resultObject
40-
}
41-
4221
// Read HTML File
4322
function readHTMLFile(path: any, callback: any) {
4423
fs.readFile(path, { encoding: 'utf-8' }, function (err, html) {
@@ -50,4 +29,4 @@ function readHTMLFile(path: any, callback: any) {
5029
})
5130
}
5231

53-
export { getUniqueCodev2, readHTMLFile, filterQueryObject, invalidValues }
32+
export { getUniqueCodev2, readHTMLFile, invalidValues }

src/models/index.ts

-17
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@ import Role from './role'
22
import User from './user'
33
import UserRole from './userrole'
44

5-
export interface FilterAttributes {
6-
id: string
7-
value: string
8-
}
9-
10-
export interface SortAttributes {
11-
id: string
12-
desc: string
13-
}
14-
15-
export interface FilterQueryAttributes {
16-
page: string | number
17-
pageSize: string | number
18-
filtered: string
19-
sorted: string
20-
}
21-
225
const models = {
236
Role,
247
User,

0 commit comments

Comments
 (0)