0

Using CosmoDb with MongoDb api from c# I can update a document with filter condition rather than using the Id. For example this code work fine with CosmoDb with MongoDb api.

        public bool UpdateTask(MyTask myTask)
    {
        var mongoCollection = GetBsonCollectionForEdit();
        var builder = Builders<BsonDocument>.Filter;

        var filterName = builder.Eq("Name", myTask.Name);
        var filterCategory = builder.Eq("Category", myTask.Category);
        var filter = builder.And(new[] { filterName, filterCategory });

        var replaceUpdate = Builders<BsonDocument>.Update;
        var ret = mongoCollection.ReplaceOne(filter, myTask.ToBsonDocument());

        return ret.ModifiedCount == 1;
    }

Can I do the same thing with CosmoDb using the SQL DocumentDb api ? (Without implement UDF or StoredPoc)

Thanks

1 Answer 1

1

No, but you can perform a query for the criteria using CreateDocumentQuery, then iterate through the matching IDs and perform an update on each of them using ReplaceDocumentAsync.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.