easymongo 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -2
- data/easymongo.gemspec +2 -2
- data/lib/easymongo/query.rb +8 -17
- 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: 3cc4edad2a676e0964494e8c729f585acf7d930f
|
4
|
+
data.tar.gz: 2fd7275fd201b7e9d55e70742b273d582403dbf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 371cf2d329cb4e08e209ed381fefe03a3d1afe81ad63480fa24dfbc9e029ae62d37a55e9c643274a9a9644632e65d4818e24ac04bd3629c103a300c20f3113ca
|
7
|
+
data.tar.gz: 05fbd236f15b4cc1255e5fda076e0d394c5a44fef231ca65b003e549b25e518216d6e9f62b2d874204d2787608bae5b68a7ab6bf7a800f077e19cfd6ba3e3824
|
data/CHANGELOG.md
CHANGED
data/easymongo.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'easymongo'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.date = '2017-07-
|
3
|
+
s.version = '0.0.9'
|
4
|
+
s.date = '2017-07-26'
|
5
5
|
s.summary = "Super Easy MongoDB client"
|
6
6
|
s.description = "The way MongoDB for Ruby should be, can't get easier than this"
|
7
7
|
s.authors = ["Fugroup Limited"]
|
data/lib/easymongo/query.rb
CHANGED
@@ -31,14 +31,14 @@ module Easymongo
|
|
31
31
|
# Insert, add oid
|
32
32
|
data, values = args.size == 1 ? [{'_id' => oid}, *args] : args
|
33
33
|
|
34
|
+
# Normalize attributes
|
35
|
+
data, values = ids(data), ids(values)
|
36
|
+
|
34
37
|
# Using set and unset so we don't store nil in the db
|
35
38
|
options = {
|
36
39
|
:$set => values.select{|k, v| !v.nil?}, :$unset => values.select{|k, v| v.nil?}
|
37
40
|
}.delete_if{|k, v| v.empty?}
|
38
41
|
|
39
|
-
# Normalize data
|
40
|
-
data = ids(data)
|
41
|
-
|
42
42
|
# Update the collection
|
43
43
|
result = client[coll].update_one(data, options, :upsert => true)
|
44
44
|
|
@@ -113,9 +113,6 @@ module Easymongo
|
|
113
113
|
# Support passing id as string
|
114
114
|
data = {'_id' => data} if !data or data.is_a?(String)
|
115
115
|
|
116
|
-
# Merge in defaults
|
117
|
-
data = defaults.merge(data)
|
118
|
-
|
119
116
|
# Turn all keys to string
|
120
117
|
data = data.stringify_keys
|
121
118
|
|
@@ -123,7 +120,11 @@ module Easymongo
|
|
123
120
|
data['_id'] = data.delete('id') if data['id']
|
124
121
|
|
125
122
|
# Convert ids to BSON ObjectId
|
126
|
-
data.each
|
123
|
+
data.each do |k, v|
|
124
|
+
if v.is_a?(String) and v =~ /^[0-9a-fA-F]{24}$/
|
125
|
+
data[k] = oid(v)
|
126
|
+
end
|
127
|
+
end
|
127
128
|
|
128
129
|
# Return data
|
129
130
|
data
|
@@ -134,16 +135,6 @@ module Easymongo
|
|
134
135
|
return BSON::ObjectId.new if v.nil?; BSON::ObjectId.from_string(v) rescue v
|
135
136
|
end
|
136
137
|
|
137
|
-
# Set temporary defaults. Useful for logged in users.
|
138
|
-
def defaults=(val)
|
139
|
-
s[:defaults] = val
|
140
|
-
end
|
141
|
-
|
142
|
-
# Get defaults
|
143
|
-
def defaults
|
144
|
-
s[:defaults] || {}
|
145
|
-
end
|
146
|
-
|
147
138
|
private
|
148
139
|
|
149
140
|
# Get the request store
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easymongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|