Select * Cosmos DB 中具有 SQL API 的特定属性除外

Select * Except particular properties in Cosmos DB with SQL API

考虑以下内容,我有一个看起来像这样的文档:

"id": 2
"properties": {
    "desired": {
        "Property1": 10,
        "Property2": 1,
        "Property3": 1,
        "$metadata": { 
        ...
        },
        "$version": 53
    }
},

我想从文档中获取除 $metadata$version 之外的所有内容,显而易见的解决方案是:

SELECT c["Property1"], c["Property2"] .... FROM c where c["id"] = "2"

但是,我的文档可能会动态扩展,因此上述内容不是最理想的。因此,我认为最好只排除 $metadata$version。我在 Whosebug 上查看了不同的“有趣”解决方案,其中一个建议创建一个临时 table.

不幸的是,查询需要非常高效,因为我想减少使用的 RU 数量。另外我真的很想避免处理代码中的排除。

因此,如何从我的文档中排除特定的“列”,而不编写过长的查询,其中可能包括创建临时 tables。

Cosmos DB 不支持“Project Away”。您将需要指定要投影的属性或使用 * 和 return 所有属性。