Skip to content

Commit e61c55b

Browse files
authored
feat(aggregation): support for 5.1 operators VSCODE-302 (#357)
1 parent 1c09841 commit e61c55b

File tree

3 files changed

+85
-4
lines changed

3 files changed

+85
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@
948948
"mocha": "^8.2.1",
949949
"mocha-junit-reporter": "^2.0.0",
950950
"mocha-multi": "^1.1.3",
951-
"mongodb-ace-autocompleter": "^0.6.0",
951+
"mongodb-ace-autocompleter": "^0.8.0",
952952
"mongodb-build-info": "^1.2.0",
953953
"mongodb-runner": "^4.8.3",
954954
"node-loader": "^0.6.0",

snippets/stage-autocompleter.json

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,42 @@
8282
],
8383
"description": "Returns a count of the number of documents at this stage of the aggregation pipeline."
8484
},
85+
"MongoDB Aggregations $densify": {
86+
"prefix": "$densify",
87+
"body": [
88+
"/**",
89+
" * field: The required field to densify.",
90+
" * partitionByFields: The set of fields that acts as a compound key to define each partition.",
91+
" * range: {",
92+
" * step: The amount to increment the field value in each document.",
93+
" * unit: If specified field must evaluate to a date for every document in the collection, otherwise must evaluate to a numeric.",
94+
" * bounds: A string or array of numeric/date bounds, corresponding to the type of the field.",
95+
" * }",
96+
" */",
97+
"\\$densify: {",
98+
" field: ${1:string},",
99+
" partitionByFields: [${2:string}, ${3:string}, ...],",
100+
" range: {",
101+
" step: ${4:number},",
102+
" unit: ${5:string},",
103+
" bounds: [${6:lowerbound}, ${7:upperbound}, ...]",
104+
" }",
105+
"}"
106+
],
107+
"description": "Creates new documents to eliminate the gaps in the time or numeric domain at the required granularity level."
108+
},
109+
"MongoDB Aggregations $documents": {
110+
"prefix": "$documents",
111+
"body": [
112+
"/**",
113+
" * expression: Any valid expression.",
114+
" */",
115+
"\\$documents: {",
116+
" ${1:expression}",
117+
"}"
118+
],
119+
"description": "Returns literal results for a full-text search."
120+
},
85121
"MongoDB Aggregations $facet": {
86122
"prefix": "$facet",
87123
"body": [
@@ -318,7 +354,7 @@
318354
"prefix": "$search",
319355
"body": [
320356
"/** ",
321-
" * index: the name of the Search index.",
357+
" * index: The name of the Search index.",
322358
" * text: Analyzed search, with required fields of query and path, the analyzed field(s) to search.",
323359
" * term: Un-analyzed search.",
324360
" * compound: Combines ops.",
@@ -337,6 +373,48 @@
337373
],
338374
"description": "Performs a full-text search on the specified field(s)."
339375
},
376+
"MongoDB Aggregations $searchMeta": {
377+
"prefix": "$searchMeta",
378+
"body": [
379+
"/**",
380+
" * index: The name of the Search index.",
381+
" * count: The count of the results.",
382+
" * facet: {",
383+
" * operator: Analyzed search, with required fields of query and path, can either be replaced with the name of a valid operator.",
384+
" * facets: {",
385+
" * stringFacet: Narrows search results based on unique string values, with required fields of type and path.",
386+
" * numberFacet: Narrows search results by breaking them up into separate ranges of numbers, with required fields of type, path, and boundaries.",
387+
" * dateFacet: Narrows search results by breaking them up into separate ranges of dates, with required fields of type, path, and boundaries.",
388+
" * }",
389+
" * }",
390+
" */",
391+
"\\$searchMeta: {",
392+
" index: ${1:string},",
393+
" facet: {",
394+
" operator: {",
395+
" text: {",
396+
" query: ${2:string},",
397+
" path: ${3:string}",
398+
" }",
399+
" },",
400+
" facets: {",
401+
" ${4:stringFacet}: {",
402+
" type: ${5:string},",
403+
" path: ${6:string},",
404+
" numBuckets: ${7:integer}",
405+
" },",
406+
" numberFacet: {",
407+
" type: 'number',",
408+
" path: ${8:string},",
409+
" boundaries: [${9:lowerbound}, ${10:upperbound}, ...],",
410+
" default: ${11:string}",
411+
" }",
412+
" }",
413+
" }",
414+
"}"
415+
],
416+
"description": "Performs a full-text search on the specified field(s) and gets back only the generated search meta data from a query."
417+
},
340418
"MongoDB Aggregations $set": {
341419
"prefix": "$set",
342420
"body": [
@@ -374,8 +452,8 @@
374452
" ${3:path}: {",
375453
" ${4:function}: ${5:functionArgs},",
376454
" window: {",
377-
" documents: [${6:lowerBound}, ${7:upperBound}],",
378-
" range: [${8:lowerBound}, ${9:upperBound}],",
455+
" documents: [${6:lowerbound}, ${7:upperbound}],",
456+
" range: [${8:lowerbound}, ${9:upperbound}],",
379457
" unit: ${10:string}",
380458
" }",
381459
" },",

src/test/suite/snippets/stageAutocompleter.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const STAGE_LABELS = [
1515
'MongoDB Aggregations $bucketAuto',
1616
'MongoDB Aggregations $collStats',
1717
'MongoDB Aggregations $count',
18+
'MongoDB Aggregations $densify',
19+
'MongoDB Aggregations $documents',
1820
'MongoDB Aggregations $facet',
1921
'MongoDB Aggregations $geoNear',
2022
'MongoDB Aggregations $graphLookup',
@@ -24,6 +26,7 @@ const STAGE_LABELS = [
2426
'MongoDB Aggregations $lookup',
2527
'MongoDB Aggregations $match',
2628
'MongoDB Aggregations $merge',
29+
'MongoDB Aggregations $metaSearch',
2730
'MongoDB Aggregations $out',
2831
'MongoDB Aggregations $project',
2932
'MongoDB Aggregations $redact',

0 commit comments

Comments
 (0)