mongo_light 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongo_light/document.rb +10 -0
- data/lib/mongo_light/version.rb +1 -1
- metadata +1 -1
data/lib/mongo_light/document.rb
CHANGED
@@ -26,6 +26,16 @@ module MongoLight
|
|
26
26
|
c = collection || self.collection
|
27
27
|
c.find(map(selector), map_options(opts))
|
28
28
|
end
|
29
|
+
def find_and_modify(options = {}, collection = nil)
|
30
|
+
raw = options.delete(:raw) || false
|
31
|
+
options[:query] = map(options[:query]) if options[:query]
|
32
|
+
options[:update] = map(options[:update]) if options[:update]
|
33
|
+
options[:sort] = map_options(options[:sort]) if options[:sort]
|
34
|
+
c = collection || self.collection
|
35
|
+
found = c.find_and_modify(options)
|
36
|
+
return nil if found.nil?
|
37
|
+
raw ? unmap(found) : self.new(unmap(found))
|
38
|
+
end
|
29
39
|
def remove(selector = {}, options = {}, collection = nil)
|
30
40
|
c = collection || self.collection
|
31
41
|
c.remove(map(selector), options)
|
data/lib/mongo_light/version.rb
CHANGED