Skip to content

Instantly share code, notes, and snippets.

@jseibert
Created May 10, 2012 20:24
Show Gist options
  • Save jseibert/2655661 to your computer and use it in GitHub Desktop.
Save jseibert/2655661 to your computer and use it in GitHub Desktop.
# Warm the db by doing a find before the find_and_modify
find_record(
'devices',
{ :did => data[:did], :organization_id => BSON::ObjectId(data[:organization_id]) },
{ :fields => { :_id => 1 } }
)
device = find_and_modify_record(
'devices',
{ :did => data[:did], :organization_id => BSON::ObjectId(data[:organization_id]) },
{ '$set' => { :did => data[:did], :organization_id => BSON::ObjectId(data[:organization_id]) } },
{ :fields => { :_id => 1 }, :upsert => true }
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment