rao-query 0.0.48.pre → 0.0.49.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -3
- data/app/parsers/rao/query/condition_parser.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caa1108b2190909256712d1c97cfe7fa5d5383ac39ece955225612db16e53ea3
|
4
|
+
data.tar.gz: f69148a47ce87ae69952ca896ba0b0b7a3dee8f5075ed6b2dc7e72bc65013872
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de6981ceafb1a92e5525a34cf489607aef446f5c537a010ba33d2eeb482c1c3b42ad99381d78609c2c57cc3926b0d6797cafd0a5d9e0932557790748b04dab8
|
7
|
+
data.tar.gz: b5a87d1251a4f8e2c6557ad13920f84f88f89e15309ad99b73a53c36bd52f3e5e6e5a6062247a441e43cae05ed19108b4da5a023e480425c15d5747e914bcf01
|
data/README.md
CHANGED
@@ -1,10 +1,54 @@
|
|
1
1
|
# Rails Add-Ons Query
|
2
|
-
Short description and motivation.
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
Provides filtering and sorting of collections at controller level. Useful for
|
4
|
+
UIs or APIs that display any collection of records.
|
5
|
+
|
6
|
+
## Basic Usage
|
7
|
+
|
8
|
+
Include the concern in your controller and change you index action to use
|
9
|
+
conditions coming from the query string:
|
10
|
+
|
11
|
+
# app/controllers/posts_controller.rb
|
12
|
+
class PostsController < ApplicationController
|
13
|
+
include Rao::Query::Controller::QueryConcern
|
14
|
+
|
15
|
+
def index
|
16
|
+
@posts = with_conditions_from_query(Post).all
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
### Using limit
|
21
|
+
|
22
|
+
### Using offset
|
23
|
+
|
24
|
+
### Using order
|
25
|
+
|
26
|
+
### Using includes
|
27
|
+
|
28
|
+
The includes parameter is used to eager load associations.
|
29
|
+
|
30
|
+
#### has many
|
31
|
+
|
32
|
+
Assume you have posts that have many comments. You can have the comments
|
33
|
+
included in your query like this:
|
34
|
+
|
35
|
+
http://localhost:3000/posts?includes[]=comments
|
36
|
+
|
37
|
+
## Usage with rao-api-resources_controller
|
38
|
+
|
39
|
+
rao-api_resources_controller comes with support for rao-query. You just have
|
40
|
+
to include the QueryConcern to enable it. There is no need to overwrite the
|
41
|
+
index action:
|
42
|
+
|
43
|
+
# app/controllers/posts_controller.rb
|
44
|
+
class PostsController < Rao::Api::ResourcesController::Base
|
45
|
+
include Rao::Query::Controller::QueryConcern
|
46
|
+
|
47
|
+
#...
|
48
|
+
end
|
6
49
|
|
7
50
|
## Installation
|
51
|
+
|
8
52
|
Add this line to your application's Gemfile:
|
9
53
|
|
10
54
|
```ruby
|
@@ -12,17 +56,21 @@ gem 'rao-query'
|
|
12
56
|
```
|
13
57
|
|
14
58
|
And then execute:
|
59
|
+
|
15
60
|
```bash
|
16
61
|
$ bundle
|
17
62
|
```
|
18
63
|
|
19
64
|
Or install it yourself as:
|
65
|
+
|
20
66
|
```bash
|
21
67
|
$ gem install rao-query
|
22
68
|
```
|
23
69
|
|
24
70
|
## Contributing
|
71
|
+
|
25
72
|
Contribution directions go here.
|
26
73
|
|
27
74
|
## License
|
75
|
+
|
28
76
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -73,7 +73,7 @@ module Rao
|
|
73
73
|
# end
|
74
74
|
|
75
75
|
def extract_table_column_and_operator(string)
|
76
|
-
if string =~ /([\.a-
|
76
|
+
if string =~ /([\.a-z0-9_]{1,})\(([a-z0-9_]{2,})\)/
|
77
77
|
table_and_column = $~[1]
|
78
78
|
operator = $~[2]
|
79
79
|
column, table_or_association = table_and_column.split('.').reverse
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rao-query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.49.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: 1.3.1
|
223
223
|
requirements: []
|
224
|
-
rubygems_version: 3.
|
224
|
+
rubygems_version: 3.4.11
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Simple Filter Queries for Ruby on Rails.
|