-
Notifications
You must be signed in to change notification settings - Fork 57
/
filterOperations.js
124 lines (123 loc) · 2.74 KB
/
filterOperations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const FilterOperations = {
escape: {
template: function escape(options, attr) {
return `${attr}`;
},
rawValue: true,
},
size: {
template: function size(options, attr, name) {
return `size(${name})`;
},
strict: false,
},
type: {
template: function attributeType(options, attr, name, value) {
return `attribute_type(${name}, ${value})`;
},
strict: false,
},
ne: {
template: function ne(options, attr, name, value) {
return `${name} <> ${value}`;
},
strict: false,
},
eq: {
template: function eq(options, attr, name, value) {
return `${name} = ${value}`;
},
strict: false,
},
gt: {
template: function gt(options, attr, name, value) {
return `${name} > ${value}`;
},
strict: false,
},
lt: {
template: function lt(options, attr, name, value) {
return `${name} < ${value}`;
},
strict: false,
},
gte: {
template: function gte(options, attr, name, value) {
return `${name} >= ${value}`;
},
strict: false,
},
lte: {
template: function lte(options, attr, name, value) {
return `${name} <= ${value}`;
},
strict: false,
},
between: {
template: function between(options, attr, name, value1, value2) {
return `(${name} between ${value1} and ${value2})`;
},
strict: false,
},
begins: {
template: function begins(options, attr, name, value) {
return `begins_with(${name}, ${value})`;
},
strict: false,
},
exists: {
template: function exists(options, attr, name) {
return `attribute_exists(${name})`;
},
strict: false,
},
notExists: {
template: function notExists(options, attr, name) {
return `attribute_not_exists(${name})`;
},
strict: false,
},
contains: {
template: function contains(options, attr, name, value) {
return `contains(${name}, ${value})`;
},
strict: false,
},
notContains: {
template: function notContains(options, attr, name, value) {
return `not contains(${name}, ${value})`;
},
strict: false,
},
value: {
template: function (options, attr, name, value) {
return value;
},
strict: false,
canNest: true,
},
name: {
template: function (options, attr, name) {
return name;
},
strict: false,
canNest: true,
},
eqOrNotExists: {
template: function eq(options, attr, name, value) {
return `(${name} = ${value} OR attribute_not_exists(${name}))`;
},
strict: false,
},
field: {
template: function (options, _, fieldName) {
return fieldName !== undefined ? `${fieldName}` : "";
},
strict: false,
canNest: true,
rawField: true,
},
};
module.exports = {
FilterOperations,
};