I tried to create a view via Robo3T. The command executes successfully, but the view is always empty, no matter how I specify the aggregation pipeline for the view. Example:
db.createView("testView","originCollection", [{
$project : {
_id: 1
}
}])
Does CosmosDB even support views for MongoDB?
Edit: As Kevin Smith asked in comments db.testView.stats()
returns:
{
"_t" : "CollStatsResponse",
"ok" : 1,
"ns" : "myDb.testView",
"count" : 0.0,
"size" : 0,
"avgObjSize" : 0,
"numExtents" : 0,
"lastExtentSize" : 0,
"paddingFactor" : 0,
"systemFlags" : 0,
"userFlags" : 0,
"totalIndexSize" : 0,
"indexSizes" : {
"indexSizes" : {}
}
}
From the details that you have given, it looks like it's treating the view as just another collection and nothing is happening when you create a view (I've seen this with other commands it just continues without any errors).
When you call stats on a view you'd normally end up with the following
db.testView.stats()
{
"ok" : 0,
"errmsg" : "Namespace test.testView is a view, not a collection",
"code" : 166,
"codeName" : "CommandNotSupportedOnView"
}
Also, looking at the documentation (https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb-feature-support#administration-commands) the Administration Commands don't support createView
.