[{
$project: {
OrderId: 1,
Sum2Col: {
$add: [
'$OrderId',
3
]
},
cond: {
$cond: {
'if': {
$gte: [
'$OrderId',
500
]
},
then: 'Id lớn hơn 500',
'else': 'Id nhỏ hơn 500'
}
},
'switch': {
$switch: {
branches: [
{
'case': {
$gte: [
'$OrderId',
800
]
},
then: 'Giỏi!'
},
{
'case': {
$gte: [
'$OrderId',
500
]
},
then: 'Khá.'
},
{
'case': {
$gte: [
'$OrderId',
0
]
},
then: 'TB.'
}
],
'default': 'Ngoại hạng.'
}
},
pheptoan: '---- +,-,x,:, abs ----',
add: {
$add: [
10,
3
]
},
subtract: {
$subtract: [
10,
3
]
},
multiply: {
$multiply: [
10,
3
]
},
divide: {
$divide: [
10,
3
]
},
abs: {
$abs: -1
},
cmpTo250: {
$cmp: [
'$OrderId',
250
]
},
acos: {
$acos: -1
},
asin: {
$asin: 1
},
type_string: '---- Kiểu String ----',
toUpper: {
$toUpper: 'Abc123'
},
toLower: {
$toLower: 'Abc123'
},
concat: {
$concat: [
'abc',
' - ',
'123'
]
},
DateStr: {
$dateFromString: {
dateString: '2017-02-25T12:10:40.787',
timezone: 'America/New_York'
}
},
DateStr2: {
$dateFromString: {
dateString: '25-02-2017',
format: '%d-%m-%Y'
}
},
type_datetime: '---- Kiểu datetime ----',
DateNow: {
$toDate: 1658803582040
},
ParseDate: {
$toDate: {
$toLong: 259200000
}
},
concatArrays: {
$concatArrays: [
[
'a',
'b'
],
[
'c',
'd'
]
]
},
first: {
$arrayElemAt: [
[
5,
6,
7,
8,
9
],
0
]
},
last: {
$arrayElemAt: [
[
'a',
'b',
7,
8,
9
],
-1
]
},
isAllTrue: {
$allElementsTrue: [
[
true,
true,
1,
2,
-3
]
]
},
anyElementTrue: {
$anyElementTrue: [
[
0,
false,
1
]
]
}
}
}]
0 Nhận xét