azure-cosmosdb

Cannot create index in Azure DocumentDb with Mongodb protocol

冷暖自知 提交于 2020-01-11 05:06:05
问题 Now I know that the Unique Index is not supported in DocumentDb, but why I cannot create a normal index using createIndex()? In mongo shell: > db.product.createIndex({itemId:1}) { "_t" : "OKMongoResponse", "ok" : 1 } but the collection seems unchange: > db.product.getIndexes() [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_1", "ns" : "admin.product" } ] I also find Mongodb API Compatibility slide here. It told us that we can use createIndex function in mongodb to create non-unique index.

Cosmos Mongo API “In” Array expression issue

↘锁芯ラ 提交于 2020-01-11 04:11:26
问题 Are there issues with the IN expression? We are having issues where it doesn't find the results we are asking for even though it exists? { "SerialNumber": "V8073023", "_t": "DeviceEventDataEvent", "EventType": NumberInt(4), "isDeleted": { $in: [false,null] }, "EventNumber": 122 } Returns the document correctly, however when using IN { "SerialNumber": "V8073023", "_t": "DeviceEventDataEvent", "EventType": NumberInt(4), "isDeleted": { $in: [false,null] }, "EventNumber": { $in: [122] } } No data

How _ts change in DocumentDB

眉间皱痕 提交于 2020-01-10 04:54:09
问题 I have a question regarding the _ts field within the documentdb. How is it determined? My understanding is that when a document is added/altered it gets a new _ts. Are there any chance that two documents have the same _ts? If so, does it happen only if those documents are added at the exact time (in terms of milli second). 回答1: _ts is a system property denoting when a document was last updated (e.g. create or replace). _ts is represented as a POSIX or epoch time value. In other words, its the

Grouping by a field in DocumentDB

依然范特西╮ 提交于 2020-01-09 07:50:13
问题 Is it possible, in some way, to group upon a field in DocumentDB, stored procedure or not? Let's say I have the following collection: [ { name: "Item A", priority: 1 }, { name: "Item B", priority: 2 }, { name: "Item C", priority: 2 }, { name: "Item D", priority: 1 } ] I would like to get all the items in the highest priority group (priority 2 in this case). I do not know what value of the highest priority. I.e.: [ { name: "Item B", priority: 2 }, { name: "Item C", priority: 2 } ] With some

Cosmos DB - Deleting a document

和自甴很熟 提交于 2020-01-09 05:22:08
问题 How can I delete an individual record from Cosmos DB? I can select using SQL syntax: SELECT * FROM collection1 WHERE (collection1._ts > 0) And sure enough all documents (analogous to rows?) are returned However this doesn't work when I attempt to delete DELETE FROM collection1 WHERE (collection1._ts > 0) How do I achieve that? 回答1: The DocumentDB API's SQL is specifically for querying . That is, it only provides SELECT , not UPDATE or DELETE . Those operations are fully supported, but require

Cosmos DB - Deleting a document

冷暖自知 提交于 2020-01-09 05:21:26
问题 How can I delete an individual record from Cosmos DB? I can select using SQL syntax: SELECT * FROM collection1 WHERE (collection1._ts > 0) And sure enough all documents (analogous to rows?) are returned However this doesn't work when I attempt to delete DELETE FROM collection1 WHERE (collection1._ts > 0) How do I achieve that? 回答1: The DocumentDB API's SQL is specifically for querying . That is, it only provides SELECT , not UPDATE or DELETE . Those operations are fully supported, but require

Date Between Query in Cosmos DB

我的梦境 提交于 2020-01-07 05:46:09
问题 I am in the building a simple event store in Cosmos DB that has documents that are structured something like this: { "id": "e4c2bbd0-2885-4fb5-bcca-90436f79f155", "entityType": "contact", "history": [ { "startDate": 1504656000, "endDate": 1504656000, "Name": "John" }, { "startDate": 1504828800, "endDate": 1504828800, "Name": "Jon" } ] } This might not bet the most efficient way to store it but this is what I am starting with. But I want to be able to query all contact documents out of the db

Cosmos DB - Indexing Policy Settings

故事扮演 提交于 2020-01-06 08:13:02
问题 I am using the azure cli in order to set my indexing policy. I am using the following JSON: { "indexingMode": "consistent", "automatic": true, "includedPaths": [ { "path": "/ttl/?", "indexes": [ { "kind": "Range", "dataType": "Number", "precision": -1 } ] } ], "excludedPaths": [ { "path": "/*" } ] } The script reports no errors have occurred, however when I log into the portal and look at the indexing policy, it shows the following: { "indexingMode": "consistent", "automatic": true,

Node Async - Callback was already called - using 2 for loops and an if statement

南楼画角 提交于 2020-01-06 07:27:18
问题 Could someone please explain why I keep seeing the Error: Callback was already called . I feel I have covered all cases - so why would be 'already called': function addVertices(outercallback) { async.forEachLimit(fullData, 25, function (data, innercallback) { myJson.matches.forEach(function (oMatches) { if (data.$.id == oMatches.SourceId) { oMatches.Ids.forEach(function (oId) { client.execute("g.addV('test').property('id', \"" + oId + "\")", {}, (err, results) => { if (err) { return

Access a Cosmos DB in a virtual network from a Function app

纵然是瞬间 提交于 2020-01-06 07:10:25
问题 Apologies for the long post, but I've been working for days on this issue and I can't seem to find the solution. Situation I want to restrict access to a Cosmos DB in Azure by placing it in a Virtual Network (VNet) and only allow access via a Function app. Approach The first part is simple: Create a Cosmos DB and a VNet and configure the service endpoint of the database as described here. Connecting a Function app to a VNet can be done in two ways. Using a Gateway Following this guide, I've