EDIT: I see downvote for this question, editing my question to add clarity and readability.
I'm from SQL background ramping up on Document DB Query syntax. I'm looking for document db equivalent syntax for the following T-SQL Queries. Any help appreciated.
Select * from c where c.header.TimeStampField >= 'Time Stamp Constant'
Select * from c where Upper(c.stringifield) = "lowercase to uppercase"
Is it possible to delete the documents thru a query ? like RDBMS queries (delete from table?)
答案 0 :(得分:1)
Your queries #1 and #2 should work exactly as specified.
Query #3 is not possible. However, the total size of documents is returned in the documentsCount
property in the x-ms-resource-usage
response header. That's a new feature that may or may not be supported by the SDK you are using though. So, you can get a count of all documents by going through all of the lines. Here is a fully worked example of doing it in a stored procedure. Alternatively, you could do SELECT 1 FROM c
and bring back all of the 1's and count/sum them.
It is not possible to delete documents through a query like in SQL. You can do it in a sproc or use the client side functionality for delete document. In both cases, you'd need to first query the docs and then delete them one at a time.
答案 1 :(得分:1)
借助DocumentDB的最新聚合支持(2017年2月),您现在可以使用以下内容生成计数:
SELECT VALUE COUNT(1)
FROM mydocuments d
这也适用于过滤器。例如:
SELECT VALUE COUNT(1)
FROM mydocuments d
WHERE d.foo = "bar"
还支持最小/最大/平均/总和。
答案 2 :(得分:0)
要进一步深入了解查询语言,您可以使用playground @ https://www.documentdb.com/sql/demo