我试图使用Rails,CouchRest更新对象集合中的参数。
我现在就是这么做的,
class User
property :country
property :some_flag
end
@users = User.by_country(:key => 'country-name')
@users.each do |user|
user.update_attributes({:some_flag => 'true'})
end每当用户对象的update_attributes失败时,我希望回滚整个事务。我怎样才能做到这一点?
我正在使用CouchDB。Rails、CouchRest和使用ActiveRecord而不是。
发布于 2012-11-01 08:04:14
CouchDB不显式地支持事务,但是有一种叫做“批量更新”的东西可能会有帮助:
Request
更新的示例数据:
{
"all_or_nothing": true,
"docs": [
{"_id": "0", "_rev": "1-62657917", "integer": 10, "string": "10"},
{"_id": "1", "_rev": "2-1579510027", "integer": 2, "string": "2"},
{"_id": "2", "_rev": "2-3978456339", "integer": 3, "string": "3"}
]
}https://stackoverflow.com/questions/13170247
复制相似问题