megas
megas

Reputation: 21791

How to optimize update_all calls

Currently, I'm doing the update_all with concatenation like this:

collection.update_all(flag: false)
collection.update_all(["description = CONCAT(description, ?)", 'not_available'])

Is it possible to do it at once?

Obviously, this construction doesn't work:

collection.udpate_all(flag: false, ["description = CONCAT(description, ?)", 'not_available'])

Upvotes: 0

Views: 87

Answers (1)

nuaky
nuaky

Reputation: 2086

update_all can take array, so you should be able to do something like this:

collection.udpate_all([
  "description = CONCAT(description, ?)", flag = ?,
  'not_available',
  false
])

Upvotes: 1

Related Questions