horza 0.3.0 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +16 -18
- data/lib/horza/adapters/options.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5bdfed1fbc5daf7a0e9e5ff11203ea7d156937b
|
4
|
+
data.tar.gz: da4e31d4c06cf95acdacc53b471337d1953f9805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7eaf2d947317ce23752eec62b16d1186148cd6461f9f597bfda7fefca65a5bb173d454efe7ddd62fa49ecafcf1b84e958a641d09e79ad6c7028a67396c1897
|
7
|
+
data.tar.gz: 185a1dae46acca276649cf316faf1768ac412764958a6868bf822496ff78cf5b23032da51e4536114b9a1182743204f3f958e10ae5c53347814d1b33cd133729
|
data/README.md
CHANGED
@@ -31,6 +31,20 @@ user.update!(options) # Update record - raise error on fail
|
|
31
31
|
user.delete(options) # Delete record - return nil on fail
|
32
32
|
user.delete!(options) # Delete record - raise error on fail
|
33
33
|
user.association(target: :employer, via: []) # Traverse association
|
34
|
+
|
35
|
+
conditions = { last_name: 'Turner' }
|
36
|
+
|
37
|
+
# Ordering
|
38
|
+
user.find_all(conditions: conditions, order: { last_name: :desc })
|
39
|
+
|
40
|
+
# Limiting
|
41
|
+
user.find_all(conditions: conditions, limit: 20)
|
42
|
+
|
43
|
+
# Offset
|
44
|
+
user.find_all(conditions: conditions, offset: 50)
|
45
|
+
|
46
|
+
# Eager loading associations
|
47
|
+
employer.association(target: :users, eager_load: true)
|
34
48
|
```
|
35
49
|
|
36
50
|
## Options
|
@@ -38,7 +52,7 @@ user.association(target: :employer, via: []) # Traverse association
|
|
38
52
|
**Base Options**
|
39
53
|
|
40
54
|
Key | Type | Details
|
41
|
-
|
55
|
+
--- | ---- | -------
|
42
56
|
`conditions` | Hash | Key value pairs for the query
|
43
57
|
`order` | Hash | { `field` => `:asc`/`:desc` }
|
44
58
|
`limit` | Integer | Number of records to return
|
@@ -50,27 +64,11 @@ ___ | ____ | _______
|
|
50
64
|
**Association Options**
|
51
65
|
|
52
66
|
Key | Type | Details
|
53
|
-
|
67
|
+
--- | ---- | -------
|
54
68
|
`id` | Integer | The id of the root object
|
55
69
|
`target` | Symbol | The target of the association - ie. employer.users would have a target of :users
|
56
70
|
`eager_load` | Boolean | Whether to eager_load the association
|
57
71
|
|
58
|
-
```ruby
|
59
|
-
conditions = { last_name: 'Turner' }
|
60
|
-
|
61
|
-
# Ordering
|
62
|
-
user.find_all(conditions: conditions, order: { last_name: :desc })
|
63
|
-
|
64
|
-
# Limiting
|
65
|
-
user.find_all(conditions: conditions, limit: 20)
|
66
|
-
|
67
|
-
# Offset
|
68
|
-
user.find_all(conditions: conditions, offset: 50)
|
69
|
-
|
70
|
-
# Eager loading associations
|
71
|
-
user.association(target: :sports_cars, via: [:employer], conditions: { make: 'Audi' }, eager_load: true)
|
72
|
-
```
|
73
|
-
|
74
72
|
## Outputs
|
75
73
|
|
76
74
|
Horza queries return very dumb vanilla entities instead of ORM response objects.
|
@@ -30,7 +30,7 @@ module Horza
|
|
30
30
|
|
31
31
|
def eager_args
|
32
32
|
raise ::Horza::Errors::InvalidOption.new('You must pass eager_load: true and defined a target') unless eager_load? && target
|
33
|
-
return target unless via
|
33
|
+
return target unless via && via.present?
|
34
34
|
|
35
35
|
via.reverse.reduce({}) do |hash, table|
|
36
36
|
if hash.empty?
|