-
-
Notifications
You must be signed in to change notification settings - Fork 90
How to achieve Concurrency Control? #177
Comments
So you would like to use $isolated? You can extend Mongorito to pass |
Actually, I want is: let test = new Test()
yield test.save()
let test1 = yield Test.findById(test.get('_id'))
let test2 = yield Test.findById(test.get('_id'))
//make some modifications to test1 and test2
yield test1.save()
yield test2.save() //should throw Exception, because the document has been modified, some fields may have been changed, Storing test2 will overwrite those fileds. See this: https://docs.mongodb.com/v3.0/tutorial/update-if-current/ My mongorito version is 2.2.0 |
How would you implement this kind of behavior? |
Interesting problem. Any solution for this yet? |
I still don't understand the problem completely. @wangzixin1113 Initially you wanted to use |
I think this is a expansibility problem since upgrading to v3, just like the problem I'm facing. We cannot easily override any built-in behavior because internal action and middleware cannot be override. If I want to change update, I cann't override it with a custom action, because other plugins might depend on it. |
@zaaack You can override any internal actions in this way: const ActionTypes = require('mongorito');
const myMiddleware = () => ({dispatch, getState}) => next => action => {
if (action.type !== UPDATE) {
// pass through any other action
return next(action);
}
// action.type is UPDATE, start customization of the action props
return next(action);
}; |
I am facing a high concurrency problem, and I found https://docs.mongodb.com/v3.0/core/write-operations-atomicity/. Is there anything like that ?
The text was updated successfully, but these errors were encountered: