forked from dresende/node-sql-query
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComparators.js
More file actions
44 lines (41 loc) · 1.13 KB
/
Comparators.js
File metadata and controls
44 lines (41 loc) · 1.13 KB
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
exports.between = function (a, b) {
return createSpecialObject({ from: a, to: b }, 'between');
};
exports.not_between = function (a, b) {
return createSpecialObject({ from: a, to: b }, 'not_between');
};
exports.like = function (expr) {
return createSpecialObject({ expr: expr }, 'like');
};
exports.not_like = function (expr) {
return createSpecialObject({ expr: expr }, 'not_like');
};
exports.eq = function (v) {
return createSpecialObject({ val: v }, 'eq');
};
exports.ne = function (v) {
return createSpecialObject({ val: v }, 'ne');
};
exports.gt = function (v) {
return createSpecialObject({ val: v }, 'gt');
};
exports.gte = function (v) {
return createSpecialObject({ val: v }, 'gte');
};
exports.lt = function (v) {
return createSpecialObject({ val: v }, 'lt');
};
exports.lte = function (v) {
return createSpecialObject({ val: v }, 'lte');
};
exports.not_in = function (v) {
return createSpecialObject({ val: v }, 'not_in');
};
function createSpecialObject(obj, tag) {
Object.defineProperty(obj, "sql_comparator", {
configurable : false,
enumerable : false,
value : function () { return tag; }
});
return obj;
}