-
Notifications
You must be signed in to change notification settings - Fork 2
/
stringAggregationOperators.js
46 lines (33 loc) · 1.04 KB
/
stringAggregationOperators.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
/*String Aggregation Operators
$concat
Concatenates any number of strings.
$split
Splits a string into substrings based on a delimiter. Returns an array of substrings.
$toLower
Converts a string to lowercase.
$toUpper
Converts a string to uppercase
$subsrtBytes
Returns the substring of a string
$indexOffBytes
Searches a string for an occurrence of a substring and returns the UTF-8 byte index of the first
occurrence
$indexOfCP
Searches a string for an occurrence of a substring and returns the UTF-8 code point index of the first occurrence.
$strcasecmp
Performs case-Insensitive string comparison and returns: 0 if two strings are equivalent
$strLenBytes
Returns the number of UTF-8 encoded bytes in a string.$concat.
$strLenCP
Returns the number of UTF-8 code points in a string.
$substrCP
Returns the substring of a string. Starts with the character at the specified LITF-8 code point (CP).
*/
db.products.aggregate([
{
$match: { remark: "NEW" },
},
{
$addFields: { newPrice: { $concat: ["$category", " ", "$subcategory"] } },
},
]);