volt-mongo 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/mongo/lib/mongo_adaptor_server.rb +17 -14
- data/volt-mongo.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35999987c336d195411aff33270e830fbf129104
|
4
|
+
data.tar.gz: e5d7bf3eaa0e4006162b86df417bdea4f11e0518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f56cca889487743ac44c319a3ff67d1dbcbdfbe8c5bdf2381dcbd96de4425711ed1aad68137a40bf871a0eb8897c41ca62ed524df565baa9d04cca849fe128
|
7
|
+
data.tar.gz: b2dac7862c22a3f1aee4e6befff3234967a67622dc9cc495786c8b74f1c3df8a823510b3efc062378deb33366d5a4e4e98d73f426b55c70494a5cee0c61362ed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -25,7 +25,7 @@ module Volt
|
|
25
25
|
db
|
26
26
|
|
27
27
|
true
|
28
|
-
rescue ::Mongo::
|
28
|
+
rescue ::Mongo::Error => e
|
29
29
|
false
|
30
30
|
end
|
31
31
|
end
|
@@ -34,18 +34,18 @@ module Volt
|
|
34
34
|
return @db if @db
|
35
35
|
|
36
36
|
if Volt.config.db_uri.present?
|
37
|
-
|
38
|
-
@db ||=
|
37
|
+
db_name = Volt.config.db_uri.split('/').last || Volt.config.db_name
|
38
|
+
@db ||= ::Mongo::Client.new(Volt.config.db_uri, database: db_name, :monitoring => false)
|
39
39
|
else
|
40
|
-
|
41
|
-
@db ||=
|
40
|
+
db_name = Volt.config.db_name
|
41
|
+
@db ||= ::Mongo::Client.new("mongodb://#{Volt.config.db_host}:#{Volt.config.db_port}", database: db_name, :monitoring => false)
|
42
42
|
end
|
43
43
|
|
44
44
|
@db
|
45
45
|
end
|
46
46
|
|
47
47
|
def insert(collection, values)
|
48
|
-
db[collection].
|
48
|
+
db[collection].insert_one(values)
|
49
49
|
end
|
50
50
|
|
51
51
|
def update(collection, values)
|
@@ -54,14 +54,14 @@ module Volt
|
|
54
54
|
to_mongo_id!(values)
|
55
55
|
# TODO: Seems mongo is dumb and doesn't let you upsert with custom id's
|
56
56
|
begin
|
57
|
-
db[collection].
|
58
|
-
rescue
|
57
|
+
db[collection].insert_one(values)
|
58
|
+
rescue => error
|
59
59
|
# Really mongo client?
|
60
|
-
if error.message[/^
|
60
|
+
if error.message[/^E11000/] && error.message['$_id_']
|
61
61
|
# Update because the id already exists
|
62
62
|
update_values = values.dup
|
63
63
|
id = update_values.delete('_id')
|
64
|
-
db[collection].
|
64
|
+
db[collection].update_one({ '_id' => id }, update_values)
|
65
65
|
else
|
66
66
|
return { error: error.message }
|
67
67
|
end
|
@@ -101,7 +101,7 @@ module Volt
|
|
101
101
|
result = result.send(method_name, *args)
|
102
102
|
end
|
103
103
|
|
104
|
-
if result.is_a?(::Mongo::
|
104
|
+
if result.is_a?(::Mongo::Collection::View)
|
105
105
|
result = result.to_a.map do |hash|
|
106
106
|
# Return id instead of _id
|
107
107
|
to_volt_id!(hash)
|
@@ -119,18 +119,21 @@ module Volt
|
|
119
119
|
query['_id'] = query.delete('id')
|
120
120
|
end
|
121
121
|
|
122
|
-
db[collection].
|
122
|
+
db[collection].delete_one(query)
|
123
123
|
end
|
124
124
|
|
125
125
|
# remove the collection entirely
|
126
126
|
def drop_collection(collection)
|
127
|
-
db.
|
127
|
+
db[collection].drop
|
128
128
|
end
|
129
129
|
|
130
130
|
def drop_database
|
131
|
-
db.
|
131
|
+
db.database.drop
|
132
132
|
end
|
133
133
|
|
134
|
+
def adapter_version
|
135
|
+
::Mongo::VERSION
|
136
|
+
end
|
134
137
|
|
135
138
|
private
|
136
139
|
# Mutate a hash to use id instead of _id
|
data/volt-mongo.gemspec
CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency 'mongo', '~> 1.
|
22
|
+
spec.add_dependency 'mongo', '~> 2.1.2'
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 2.1.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 2.1.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|