Is it possible, that Mongoid, v5.1.2 ignores the returnNewDocument
option when used with find_one_and_update
?
Consider the following code:
next_number = TrackingId.where(id: id).find_one_and_update({
:$inc => {
auto_increment_counter: 1
}
},
upsert: true,
returnNewDocument: true
).auto_increment_counter
where auto_increment_counter
is an Integer field :auto_increment_counter, type: Integer, default: 0
on that class.
However, when no document is found, it creates one, but it doesn't return the newly created document. So I get nil
back from find_one_and_update
and it breaks.