PYTHON-4226 Add Projection with aggregation expressions example (#1803)
This commit is contained in:
parent
4024a1b85d
commit
7295fe17b7
@ -866,6 +866,38 @@ class TestSampleShellCommands(IntegrationTest):
|
||||
)
|
||||
# End Aggregation Example 4
|
||||
|
||||
@client_context.require_version_min(4, 4)
|
||||
def test_aggregate_projection_example(self):
|
||||
db = self.db
|
||||
|
||||
# Start Aggregation Projection Example 1
|
||||
db.inventory.find(
|
||||
{},
|
||||
{
|
||||
"_id": 0,
|
||||
"item": 1,
|
||||
"status": {
|
||||
"$switch": {
|
||||
"branches": [
|
||||
{"case": {"$eq": ["$status", "A"]}, "then": "Available"},
|
||||
{"case": {"$eq": ["$status", "D"]}, "then": "Discontinued"},
|
||||
],
|
||||
"default": "No status found",
|
||||
}
|
||||
},
|
||||
"area": {
|
||||
"$concat": [
|
||||
{"$toString": {"$multiply": ["$size.h", "$size.w"]}},
|
||||
" ",
|
||||
"$size.uom",
|
||||
]
|
||||
},
|
||||
"reportNumber": {"$literal": 1},
|
||||
},
|
||||
)
|
||||
|
||||
# End Aggregation Projection Example 1
|
||||
|
||||
def test_commands(self):
|
||||
db = self.db
|
||||
db.restaurants.insert_one({})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user