可以将MongoDB视图与Azure CosmosDB一起使用吗? [英] Is it possible to use MongoDB Views with Azure CosmosDB?
问题描述
我试图通过Robo3T创建一个视图.该命令成功执行,但是无论我如何为视图指定聚合管道,该视图始终为空.示例:
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
}
}])
CosmosDB甚至支持MongoDB的视图吗?
Does CosmosDB even support views for MongoDB?
正如Kevin Smith在评论中所问, db.testView.stats()
返回:
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://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-feature-support#administration-commands) the Administration Commands don't support createView
.
这篇关于可以将MongoDB视图与Azure CosmosDB一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!