rethinkdb_helper 0.0.2 → 0.0.3
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 +26 -9
- data/lib/rethinkdb_helper.rb +15 -10
- data/rethinkdb_helper.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aee5dc88365446d4f305df51654cf45c28e8ae18
|
4
|
+
data.tar.gz: d39c3f9b09416b9b96c6a30927d2ab03e348a0f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d84a17a4f2faade25da3e2a3eb3d94c55c2e6f4f324540b92763e73d6f651fbfdb53a8c56d4cf2023358f697fb35faaae09bc43ecebf1204b0127908fd4b6a1a
|
7
|
+
data.tar.gz: 2070bdde98f9332fcca53bdf8985abdbdc02ec2ffc166f4b0a11346dea3ce436c0e44b20468ebe283cc5677500c6cb71782469440946c5771da01da5a2d11df7
|
data/README.md
CHANGED
@@ -4,6 +4,14 @@ My convention as a wrapper around the rethinkdb gem.
|
|
4
4
|
Under Development.
|
5
5
|
Don't use it.
|
6
6
|
|
7
|
+
This class is oriented around exploring the rethinkdb API.
|
8
|
+
|
9
|
+
I have not looked at the nobrainer gem yet. You ought to.
|
10
|
+
|
11
|
+
The rethinkdb-cli gem looks pretty simple. I'm thinking
|
12
|
+
about putting a REPL into this helper gem as well. Maybe
|
13
|
+
at a bin directory with a cli program that invokes the REPL.
|
14
|
+
|
7
15
|
## Installation
|
8
16
|
|
9
17
|
Add this line to your application's Gemfile:
|
@@ -28,25 +36,34 @@ Or install it yourself as:
|
|
28
36
|
port: 28015, # default
|
29
37
|
db: 'test', # default
|
30
38
|
table: 'test', # default
|
39
|
+
drop: false, # default - drop/delete the db
|
31
40
|
create_if_missing: true # created db/table if they are missing
|
32
41
|
)
|
33
|
-
|
34
|
-
|
35
|
-
|
42
|
+
options={}
|
43
|
+
db.insert([Hash, Hash, Hash ...], options) # takes array of hashes or json
|
44
|
+
cursor = db.search(field_name: field_value_regex)
|
36
45
|
cursor.each {|d| ap d}
|
37
46
|
etc.
|
38
47
|
```
|
39
48
|
|
40
|
-
|
49
|
+
If you were to insert an actual JSON string it would not work. Of course
|
50
|
+
being a wrapper and all that I could check the class and IF STRING then
|
51
|
+
ASSUME its a JSON string then do a JSON.parse on it to get a Hash to
|
52
|
+
pass to the native (sic.) #insert method of the rethinkdb.
|
41
53
|
|
42
|
-
|
54
|
+
Sometimes you must use symbols
|
55
|
+
to access to the (Hash) document's fields. Other times in other methods the
|
56
|
+
field name must be a string. Go figure.
|
57
|
+
|
58
|
+
|
59
|
+
## Development
|
43
60
|
|
44
|
-
|
61
|
+
** Insert Fun Here **
|
45
62
|
|
46
63
|
## Contributing
|
47
64
|
|
48
|
-
1. Fork it ( https://github.com/
|
49
|
-
2. Create your feature branch (`git checkout -b
|
65
|
+
1. Fork it ( https://github.com/MadBomber/rethinkdb_helper/fork )
|
66
|
+
2. Create your feature branch (`git checkout -b new-feature`)
|
50
67
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
-
4. Push to the branch (`git push origin
|
68
|
+
4. Push to the branch (`git push origin new-feature`)
|
52
69
|
5. Create a new Pull Request
|
data/lib/rethinkdb_helper.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
## By: Dewayne VanHoozer (dvanhoozer@gmail.com)
|
6
6
|
#
|
7
7
|
# TODO: Review the nobrainer gem to see if this stuff is moot
|
8
|
+
# TODO: Reorganize the methods into separate files within lib
|
8
9
|
#
|
9
10
|
|
10
11
|
require 'forwardable'
|
@@ -29,15 +30,10 @@ class RethinkdbHelper
|
|
29
30
|
# connect, db, table
|
30
31
|
#def_delegators :r, :connect, :db, :table
|
31
32
|
|
32
|
-
# TODO: Pass some methods to @commection for fulfillment
|
33
|
-
# close, reconnect, use, noreply_wait
|
34
33
|
def_delegators :@connection, :close, :reconnect, :use, :noreply_wait
|
35
34
|
|
36
|
-
# TODO: Pass some methods to @table for fulfillment
|
37
|
-
# filter, get, get_all, between, eq_join,
|
38
|
-
# inner_join, outer_join
|
39
35
|
def_delegators :@table, :filter, :get, :get_all, :between, :eq_join,
|
40
|
-
:inner_join, :outer_join
|
36
|
+
:inner_join, :outer_join, :index_create
|
41
37
|
|
42
38
|
# TODO: Limited to one table per instance, consider
|
43
39
|
# support for multiple table per db support;
|
@@ -140,7 +136,7 @@ class RethinkdbHelper
|
|
140
136
|
alias :flush :sync
|
141
137
|
|
142
138
|
|
143
|
-
def table_create(table_name=@
|
139
|
+
def table_create(table_name=@options[:table], options={})
|
144
140
|
@table = r.table_create(table_name, options).run
|
145
141
|
end
|
146
142
|
alias :create_table :table_create
|
@@ -161,6 +157,11 @@ class RethinkdbHelper
|
|
161
157
|
db_list.include?(db_name)
|
162
158
|
end
|
163
159
|
|
160
|
+
def db_create(db_name=@options[:db])
|
161
|
+
@db = r.db_create(db_name).run
|
162
|
+
end
|
163
|
+
alias :create_db :db_create
|
164
|
+
|
164
165
|
def db_list
|
165
166
|
r.db_list.run
|
166
167
|
end
|
@@ -182,10 +183,9 @@ class RethinkdbHelper
|
|
182
183
|
alias :wait_for_index :index_wait
|
183
184
|
alias :wait_index :index_wait
|
184
185
|
|
185
|
-
def
|
186
|
-
@table.index_create(
|
186
|
+
def create_simple_index(field_name)
|
187
|
+
@table.index_create(field_name.to_s).run
|
187
188
|
end
|
188
|
-
alias :create_index :index_create
|
189
189
|
|
190
190
|
def index_list
|
191
191
|
@table.index_list.run
|
@@ -199,6 +199,11 @@ class RethinkdbHelper
|
|
199
199
|
alias :delete_index :index_drop
|
200
200
|
alias :index_delete :index_drop
|
201
201
|
|
202
|
+
def index_wait(index_name)
|
203
|
+
@table.index_wait(index_name).run
|
204
|
+
end
|
205
|
+
alias :wait_on_index :index_wait
|
206
|
+
|
202
207
|
def drop?
|
203
208
|
@options[:drop]
|
204
209
|
end
|
data/rethinkdb_helper.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rethinkdb_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dewayne VanHoozer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|