This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure apps are created for the organization atomically by using find_and_modify | |
result = App.collection.find_and_modify({ | |
:query => { | |
:bundle_identifier => params[:id].downcase, | |
:organization_id => current_organization._id }, | |
:update => { | |
"$set" => { | |
:bundle_identifier => params[:id].downcase, | |
:organization_id => current_organization._id } }, | |
:new => true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]) }, |