mini_mongo 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/lib/mini_mongo/mapper.rb +6 -3
- data/lib/mini_mongo/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -62,12 +62,17 @@ class Post < MiniMongo::Base
|
|
62
62
|
maps :posts
|
63
63
|
end
|
64
64
|
|
65
|
+
### Examples
|
65
66
|
# Post.insert({:author => "Chuck Norris"})
|
66
67
|
# => #<Post:0x007fe5240f42c0 @id="5016af53bda74305f1000002", @author="Chuck Norris">
|
67
68
|
|
68
69
|
# Post.find("id" => "5016af53bda74305f1000002")
|
69
70
|
# => #<Post:0x007fe5240cc360 @id="5016af53bda74305f1000002", @author="Chuck Norris">
|
70
71
|
#
|
72
|
+
# Find cursor method sort, limit and skip support
|
73
|
+
# Post.find({"id" => "5016af53bda74305f1000002"}, {:limit => 1})
|
74
|
+
# => #<Post:0x007fe5240cc363 @id="5016af53bda74305f1000003", @author="Bruce Lee">
|
75
|
+
#
|
71
76
|
# Post.update("5016af53bda74305f1000002", "author" => "chuck norris")
|
72
77
|
# => #<Post:0x007fdc7c171c80 @author="chuck norris", @id="5016af53bda74305f1000002">
|
73
78
|
#
|
data/lib/mini_mongo/mapper.rb
CHANGED
@@ -8,12 +8,15 @@ module MiniMongo
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ClassMethods
|
11
|
-
def find(attrs={})
|
11
|
+
def find(attrs={}, opts={})
|
12
12
|
attrs["_id"] = BSON::ObjectId(attrs["id"]) if attrs["id"]
|
13
13
|
attrs.delete("id")
|
14
|
-
docs = self.collection.find(attrs).to_a
|
14
|
+
docs = self.collection.find(attrs, opts).to_a
|
15
15
|
if docs.empty?
|
16
|
-
raise DocumentNotFound,
|
16
|
+
raise DocumentNotFound,
|
17
|
+
"Couldn't find #{self.collection_name.capitalize}, "
|
18
|
+
"with #{attrs.to_a.collect {|p| p.join(' = ')}.join(', ')}"
|
19
|
+
"and #{opts.to_a.collect {|p| p.join(' = ')}.join(', ')}"
|
17
20
|
else
|
18
21
|
result = []
|
19
22
|
docs.each do |doc|
|
data/lib/mini_mongo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mongo
|