We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf7b610 commit 43b45d6Copy full SHA for 43b45d6
lib/mongo/collection/view/writable.rb
@@ -77,9 +77,10 @@ def find_one_and_update(document, opts = {})
77
cmd[:update] = document
78
cmd[:fields] = projection if projection
79
cmd[:sort] = sort if sort
80
- cmd[:new] = (opts[:return_document] == :after ? true : false) if opts[:return_document]
+ cmd[:new] = !!(opts[:return_document] && opts[:return_document] == :after)
81
cmd[:upsert] = opts[:upsert] if opts[:upsert]
82
- database.command(cmd).first['value']
+ value = database.command(cmd).first['value']
83
+ value unless value.nil? || value.empty?
84
end
85
86
# Remove documents from the collection.
0 commit comments