Questions tagged [findandmodify]

96 questions
11
votes
1 answer

Does findAndModify effectively lock the document to prevent read conflicts?

Assume there is document's structure like below: {_id:"session-01", status:"free"} And there are 2 concurrent operations that perform the findAndModify operation below: db.collection.findAndModify({query:{status:"free"}, update:{status:"occupied"},…
Agung Pratama
  • 3,666
  • 7
  • 36
  • 77
11
votes
1 answer

findAndModify - MongoError: exception: must specify remove or update

Id like to update an array and return the doc. Is my findAndModify syntax correct? this.becomeFollower = function(title, username, callback){ "use strict" posts.findAndModify({ query: {"title":title, "roster":"yes"}, …
Squirrl
  • 4,909
  • 9
  • 47
  • 85
6
votes
2 answers

IntelliJ IDEA: how to Find+Replace in selected text?

How can I selected, for instance, 5 lines of code, and replace all instance of myObject1 with myObject2? If subsequent lines of code contain myObject1 reference that I wish not to change. This way I can quickly apply of find & replaces in this scope…
Alex Bollbach
  • 4,370
  • 9
  • 32
  • 80
6
votes
1 answer

how can I findAndModify one record in mongodb with golang?

I want something like this: find one record in mongo db old_record update this record to new_record return old_record I write code like this: ret = nil // First, Find the obj obj := &orm.QuerySetObj{} err2 :=…
roger
  • 9,063
  • 20
  • 72
  • 119
5
votes
1 answer

Mongodb counter with initial value not zero

I would like to create a counter that starts at 1000. I.e. upsert a mongodb document as follows if the document does not exist, create it with value 1000 if the document already exists, increment the value +1 The following does not…
Carl D'Halluin
  • 1,052
  • 10
  • 14
4
votes
1 answer

I want to get the findAndModify return value of MongoTemplate as a modified value

I am currently using mongoTemplate in Spring boot like this: public MyEntity update(MyDto dto) { ... MyEntity result = mongoTemplate.findAndModify( query, update, MyEntity.class); return result; } query puts in the Criteria…
hanjiman
  • 465
  • 1
  • 6
  • 17
4
votes
5 answers

find words that matches the 3 consecutive vowels Regex

text = "Life is beautiful" pattern = r"[aeiou]{3,}" result = re.findall(pattern, text) print(result) desired result: ['beautiful'] the output I get: ['eau'] I have tried googling and etc....I found multiple answers but none of them worked!! I am…
Prab
  • 464
  • 3
  • 13
4
votes
2 answers

Mongodb findAndModify atomicity

I want to know how to reference the returned document attributes from find and use it within modify. E.x. : var totalNoOfSubjects = 5; db.people.findAndModify( { query: { name: "Tom", state: "active", rating: { $gt: 10 } }, sort: { rating:…
Raghu Katti
  • 63
  • 1
  • 5
3
votes
0 answers

Morphia/MongoDb, Using and Index with FindAndModify()

I am currently in the process of refactoring some of our mongo querying code to get rid of methods deprecated in Morphia 1.3. I am running into an issue when trying to run a find and Modify query with an index . At the moment our legacy code is…
3
votes
1 answer

Issues with mongodb/nodejs/express/mongojs and findAndModify

Currently doing a online course to learn some Node.js, Express, and MongoDB. In this course there is a api section where they teach you to do simple stuff, but i ran in to an issue, the course video shows him updating name of an item, and the api…
Benzon
  • 119
  • 6
3
votes
1 answer

FindAndUpdate vs Update in mongodb

I am using Update and FindAndModify but now I have read that Update and FindAndModify are atomic(http://docs.mongodb.org/manual/tutorial/model-data-for-atomic-operations/), So if both can do the same job, by querying for item and updating it then…
meso_2600
  • 1,940
  • 5
  • 25
  • 50
3
votes
0 answers

MongoDB FindAndModify extremely slow

i'm using mongodb and have some trouble with the speed. My collections got bigger and now contains about 7.000.000 items. As a result, the findAndModify query takes about 3 seconds. I have a index on the queried field (in my case "links", which is…
2
votes
3 answers

Detect bold texts in a cell and add ";" before those texts

I have 3 columns that have the same pattern. Here is the example: " I Love Chocolate I really love chocolate I want to drink hot chocolate I have a red bike I buy it with my own money I hate mouse I hate mouse since I was little " I want to add…
Ceciliads
  • 23
  • 3
2
votes
0 answers

findAndModify with skip

How to skip some documents when using findAndModify (or findOneAndUpdate) in MongoDB? Documentation suggests that it is possible, but findAndModify and findOneAndUpdate don't specify skip argument.
2
votes
1 answer

mongodb | How to update(findandmodify) after aggregate

I want to update some of the values according to the result after query execution. What I want to +1 the "comment_sort" value if the condition is true. Condition : If "comment_group" is 1 and "comment_sort" is greater than 0 Original DataBase…
fly high
  • 215
  • 1
  • 4
  • 18
1
2 3 4 5 6 7