更新cosmosDB Azure SQL [英] update cosmosDB azure sql

查看:85
本文介绍了更新cosmosDB Azure SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用sql API更新在cosmosDB azure上创建的文档的值.问题在于,更新/删除/插入请求无法正常工作.

I'm trying to update a value of document created on cosmosDB azure using sql api. The problem is that the requests update/ delete/ Insert don't work.

client.queryDocuments(
    collectionUrl,
    UPDATE tableC
    SET prev = 12
    WHERE condition
).toArray((err, results) => {
    if (err) res.json({ 'A': 12 });
    else {
        res.json({ 'A': 15});
    }
})

推荐答案

CosmosDB SQL 不是 ANSI SQL实现.它仅支持以某种相似的方式进行查询,但这不是一回事.

CosmosDB SQL is not ANSI SQL implementation. It supports just querying in a somewhat similar manner, but it's not the same thing.

来自 Azure Cosmos简介DB:SQL API :

Azure Cosmos DB 支持使用SQL语言查询文档, 它植根于JavaScript类型系统中,并且带有 支持关系,层次和空间查询.蔚蓝 Cosmos DB查询语言是一种简单但功能强大的查询界面 JSON文件. 语言支持ANSI SQL语法的子集 并添加了JavaScript 对象,数组,对象的深度集成 构造和函数调用.

Azure Cosmos DB supports querying documents using a SQL language, which is rooted in the JavaScript type system, and expressions with support for relational, hierarchical, and spatial queries. The Azure Cosmos DB query language is a simple yet powerful interface to query JSON documents. The language supports a subset of ANSI SQL grammar and adds deep integration of JavaScript object, arrays, object construction, and function invocation.

因此,基本上,CosmosDB从SQL采用了一些语法规则和约定,但是当您仔细观察时,它是另一种野兽. Ansi SQL包含CosmosDB SQL API不具备的内容,而cosmosDB SQL具有ANSI SQL不具备的内容.

So basically CosmosDB takes some syntax rules and conventions from SQL but when you look closer it's another beast. Ansi SQL contains things CosmosDB SQL API does not have and cosmosDB SQL has things ANSI SQL does not have.

不支持整个ANSI SQL是有道理的,因为SQL是为满足关系数据操作需求而设计的. CosmosDB不是关系数据库,它的更改模型将文档作为可更改的单位而不是单个字段或集合来使用.在DoucmentDB中,您可以添加一个完整的文档,更新一个完整的文档或删除一个完整的文档.只要如此,它就不需要传统的SQL插入/更新/删除语法的复杂性.

Not having support for entire ANSI SQL makes sense, as SQL was designed for relational data manipluation needs. CosmosDB is not a relational database and its change model is working with documents as the changeable units, not individual fields or sets. In DoucmentDB you add one entire document, update one entire document, or delete one entire document. As long as this stands, it does not need the complexity of traditional SQL insert/update/delete syntax.

这篇关于更新cosmosDB Azure SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆