mongoid_query_string_interface 0.6.0 → 0.6.1
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/{README.rdoc → README.md} +28 -24
- data/lib/version.rb +1 -1
- metadata +5 -7
data/{README.rdoc → README.md}
RENAMED
@@ -1,46 +1,49 @@
|
|
1
|
-
|
1
|
+
# Overview [![build status][1]][2]
|
2
2
|
|
3
|
-
|
3
|
+
[1]: https://secure.travis-ci.org/vicentemundim/mongoid_query_string_interface.png
|
4
|
+
[2]: http://travis-ci.org/#!/vicentemundim/mongoid_query_string_interface
|
5
|
+
|
6
|
+
### About Mongoid::QueryStringInterace
|
4
7
|
|
5
8
|
Gives some methods that can parse query string parameters into a set of criterias
|
6
9
|
that Mongoid can use to perform actual queries in MongoDB databases for a given
|
7
10
|
model.
|
8
11
|
|
9
|
-
|
12
|
+
### Repository
|
10
13
|
|
11
14
|
http://github.com/vicentemundim/mongoid_query_string_interface
|
12
15
|
|
13
|
-
|
16
|
+
## Installing
|
14
17
|
|
15
18
|
This is a gem, so you can install it by:
|
16
19
|
|
17
|
-
|
20
|
+
sudo gem install mongoid_query_string_interface
|
18
21
|
|
19
22
|
Or, if you are using rails, put this in your Gemfile:
|
20
23
|
|
21
|
-
|
24
|
+
gem 'mongoid_query_string_interface'
|
22
25
|
|
23
|
-
|
26
|
+
## Usage
|
24
27
|
|
25
28
|
To use it, just extend Mongoid::QueryStringInterface in your document model:
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
class Document
|
31
|
+
include Mongoid::Document
|
32
|
+
extend Mongoid::QueryInterfaceString
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
# ... add fields here
|
35
|
+
end
|
33
36
|
|
34
37
|
Then, in your controllers put:
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
def index
|
40
|
+
@documents = Document.filter_by(params)
|
41
|
+
# ... do something like render a HTML template or a XML/JSON view of documents
|
42
|
+
end
|
40
43
|
|
41
44
|
That's it! Now you can do something like this:
|
42
45
|
|
43
|
-
|
46
|
+
http://myhost.com/documents?tags.all=ruby|rails|mongodb&tags.nin=sql|java&updated_at.gt=2010-01-01&created_at.desc&per_page=10&page=3
|
44
47
|
|
45
48
|
This would get all documents which have the tags 'ruby', 'rails' and 'mongo',
|
46
49
|
and that don't have both 'sql' and 'java' tags, and that were updated after
|
@@ -50,7 +53,7 @@ page, and the 3rd page of results.
|
|
50
53
|
You could even query for embedded documents, and use any of the Mongodb
|
51
54
|
conditional operators:
|
52
55
|
|
53
|
-
|
56
|
+
http://myhost.com/documents?comments.author=Shrek
|
54
57
|
|
55
58
|
Which would get all documents that have been commented by 'Shrek'. Basically,
|
56
59
|
any valid path that you can use in a Mongoid::Criteria can be used here, and
|
@@ -58,22 +61,23 @@ you can also append any of the Mongodb conditional operators.
|
|
58
61
|
|
59
62
|
You can sort results by passing a order_by parameter this:
|
60
63
|
|
61
|
-
|
64
|
+
http://myhost.com/documents?order_by=created_at.desc
|
62
65
|
|
63
66
|
or
|
64
67
|
|
65
|
-
|
68
|
+
http://myhost.com/documents?order_by=created_at
|
66
69
|
|
67
70
|
Which is the same as:
|
68
71
|
|
69
|
-
|
72
|
+
http://myhost.com/documents?order_by=created_at.asc
|
70
73
|
|
71
74
|
To order by more than one field:
|
72
75
|
|
73
|
-
|
76
|
+
http://myhost.com/documents?order_by=created_at.desc|updated_at.desc
|
74
77
|
|
75
78
|
Check the specs for more use cases.
|
76
79
|
|
77
|
-
|
80
|
+
## Credits
|
78
81
|
|
79
|
-
Vicente Mundim: vicente.mundim at gmail dot com
|
82
|
+
- Vicente Mundim: vicente.mundim at gmail dot com
|
83
|
+
- Wandenberg Peixoto: wandenberg at gmail dot com
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mongoid_query_string_interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Vicente Mundim
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-12-07 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: query_string_interface
|
@@ -41,7 +40,7 @@ dependencies:
|
|
41
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
41
|
none: false
|
43
42
|
requirements:
|
44
|
-
- -
|
43
|
+
- - ">="
|
45
44
|
- !ruby/object:Gem::Version
|
46
45
|
version: 2.0.2
|
47
46
|
type: :runtime
|
@@ -83,10 +82,9 @@ files:
|
|
83
82
|
- lib/mongoid_query_string_interface.rb
|
84
83
|
- lib/version.rb
|
85
84
|
- MIT_LICENSE
|
86
|
-
- README.
|
85
|
+
- README.md
|
87
86
|
- Gemfile
|
88
87
|
- Gemfile.lock
|
89
|
-
has_rdoc: true
|
90
88
|
homepage: http://github.com/vicentemundim/mongoid_query_string_interface
|
91
89
|
licenses: []
|
92
90
|
|
@@ -110,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
108
|
requirements: []
|
111
109
|
|
112
110
|
rubyforge_project: mongoid_query_string_interface
|
113
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.10
|
114
112
|
signing_key:
|
115
113
|
specification_version: 3
|
116
114
|
summary: An interface for performing queries in MongoDB using query string parameters.
|