| 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 |
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
4x
| /**
* 常量模块
*
* @author haroldhu
*/
/**
* 错误码
*/
enum ErrorCode {
DocIDError = "文档ID不合法",
CollNameError = "集合名称不合法",
OpStrError = "操作符不合法",
DirectionError = "排序字符不合法",
IntergerError = "must be integer"
}
/**
* 字段类型
*/
const FieldType = {
String: "String",
Number: "Number",
Object: "Object",
Array: "Array",
Boolean: "Boolean",
Null: "Null",
GeoPoint: "GeoPoint",
Timestamp: "Date",
Command: "Command",
ServerDate: "ServerDate"
};
/**
* 排序方向
*/
type OrderByDirection = "desc" | "asc";
/**
* 排序方向列表
*/
const OrderDirectionList = ["desc", "asc"];
/**
* 查询条件操作符
*/
type WhereFilterOp = "<" | "<=" | "==" | ">=" | ">";
/**
* 操作符列表
*/
const WhereFilterOpList = ["<", "<=", "==", ">=", ">"];
/**
* 操作符别名
*/
enum Opeartor {
lt = "<",
gt = ">",
lte = "<=",
gte = ">=",
eq = "=="
}
/**
* 操作符映射
* SDK => MongoDB
*/
const OperatorMap = {
[Opeartor.eq]: "$eq",
[Opeartor.lt]: "$lt",
[Opeartor.lte]: "$lte",
[Opeartor.gt]: "$gt",
[Opeartor.gte]: "$gte"
};
const UpdateOperatorList = [
"$set",
"$inc",
"$mul",
"$unset",
"$push",
"$pop",
"$unshift",
"$shift",
"$currentDate",
"$each",
"$position"
];
export {
ErrorCode,
FieldType,
WhereFilterOp,
WhereFilterOpList,
Opeartor,
OperatorMap,
OrderByDirection,
OrderDirectionList,
UpdateOperatorList
};
|