File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -893,6 +893,38 @@ async def test_aggregate_examples(self):
893893 print (doc )
894894 # End Aggregation Example 4
895895
896+ @env .require_version_min (4 , 4 )
897+ def test_aggregate_projection_example (self ):
898+ db = self .db
899+
900+ # Start Aggregation Projection Example 1
901+ db .inventory .find (
902+ {},
903+ {
904+ "_id" : 0 ,
905+ "item" : 1 ,
906+ "status" : {
907+ "$switch" : {
908+ "branches" : [
909+ {"case" : {"$eq" : ["$status" , "A" ]}, "then" : "Available" },
910+ {"case" : {"$eq" : ["$status" , "D" ]}, "then" : "Discontinued" },
911+ ],
912+ "default" : "No status found" ,
913+ }
914+ },
915+ "area" : {
916+ "$concat" : [
917+ {"$toString" : {"$multiply" : ["$size.h" , "$size.w" ]}},
918+ " " ,
919+ "$size.uom" ,
920+ ]
921+ },
922+ "reportNumber" : {"$literal" : 1 },
923+ },
924+ )
925+
926+ # End Aggregation Projection Example 1
927+
896928 @asyncio_test
897929 async def test_commands (self ):
898930 db = self .db
You can’t perform that action at this time.
0 commit comments