mongo_hash 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mongo_hash.rb +5 -5
- metadata +1 -1
data/lib/mongo_hash.rb
CHANGED
@@ -121,7 +121,7 @@ class MongoHash < Hash
|
|
121
121
|
|
122
122
|
def destroy()
|
123
123
|
unless @new_record == true
|
124
|
-
retval = @collection.remove({'_id' => self._id}, :
|
124
|
+
retval = @collection.remove({'_id' => self._id}, :w => 1)
|
125
125
|
@new_record = true
|
126
126
|
self._id = nil
|
127
127
|
## maybe some other things
|
@@ -142,7 +142,7 @@ class MongoHash < Hash
|
|
142
142
|
|
143
143
|
if @new_record == true
|
144
144
|
self['created_at'] = Time.now.to_i
|
145
|
-
id = @collection.insert(self, :
|
145
|
+
id = @collection.insert(self, :w => 1)
|
146
146
|
self._id = id
|
147
147
|
self.delete(:_id, false)
|
148
148
|
@new_record = false
|
@@ -157,14 +157,14 @@ class MongoHash < Hash
|
|
157
157
|
@dirty_keys.map{|key| update_hash[key] = self[key]}
|
158
158
|
delete_hash = {}
|
159
159
|
@delete_keys.map{|key| delete_hash[key] = 1}
|
160
|
-
@collection.update({'_id' => self._id}, {'$unset' => delete_hash, '$set' => update_hash }, :
|
160
|
+
@collection.update({'_id' => self._id}, {'$unset' => delete_hash, '$set' => update_hash }, :w => 1)
|
161
161
|
|
162
162
|
retval = true
|
163
163
|
else
|
164
|
-
retval = @collection.update({'_id' => self._id}, self, :
|
164
|
+
retval = @collection.update({'_id' => self._id}, self, :w => 1)
|
165
165
|
end
|
166
166
|
else
|
167
|
-
retval = @collection.update({'_id' => self._id}, {'$set' => {@subkey => self[@subkey]} }, :
|
167
|
+
retval = @collection.update({'_id' => self._id}, {'$set' => {@subkey => self[@subkey]} }, :w => 1)
|
168
168
|
end
|
169
169
|
end
|
170
170
|
@delete_keys = []
|