--
You received this message because you are subscribed to the Google
Groups "MongoMapper" group.
For more options, visit this group at
http://groups.google.com/group/mongomapper?hl=en?hl=en
You're not going to have a race condition any different on setting your counter than any other field. I use the callback strategy for a number of things. It's a great tool.
Setting a counter for your array is probably your most pragmatic solution until Mongodb adds support for querying by array length.
def sooooooooooooooo
schedule_weekend_work
end
jon
blog: http://technicaldebt.com
twitter: http://twitter.com/JonKernPA
AndrewO said the following on 11/16/10 12:29 PM:
> Hi Jamie,
>
> By "fire and forget" do you mean that it won't return error messages
> unless you enable safe mode? Thanks for reminding me of that.
>
> Still, if I understand correctly, multiple atomic modifiers within an
> update statement are atomic. It seems we'd want to use those wherever
> possible, especially since operations between multiple docs and
> collections are not.
>
> Moving on from the array/counter example to something more general,
> here's an example of what I'm worried about:
>
> https://gist.github.com/702039
>
> (This hasn't actually been run, so there may be errors. Lines with ----
>> are what I imagine the driver is doing.)
> In the promote! method, if we fire off two updates (lines 9-12),
> there's a chance that another object could read between them and make
> a decision based off of data in the middle of a change. But if we use
> the atomic operators in a single update (lines 46-51�the modify method
> is from my plugin), we don't have this problem, right?
>
> �Andrew