I'm a newbie in a document-oriented database in general and in MongoDB in particular.
This database was created by me: a collection of several disjoint segments containing integers.
I'd like to take one item in accordance with some conditions and remove it from the document.
For example, I tried to take the item with conditions:
- from [-105; 17]
- not zero
- contains in {-104, -97, -5, 0, 5}
like this
var db = client.GetDatabase("mongodbPOC");
var collection = db.GetCollection<Document>("Int");
var contains = new List<int> { -104, -97, -5, 0, 5 };
var result = collection.AsQueryable()
.Where(document => 17 >= document.Min && -105 <= document.Max)
.SelectMany(document => document.Values)
.First(val => val != 0 && contains.Contains(val));
and find it again for remove, but I sure that exists a more profitable way to do that.
