easymongo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/easymongo.gemspec +1 -1
- data/lib/easymongo.rb +1 -2
- data/lib/easymongo/document.rb +2 -1
- data/lib/easymongo/query.rb +3 -4
- data/lib/easymongo/result.rb +4 -7
- 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: a7a9dd9ec2c1e02958a6dea51c016098503339f1
|
4
|
+
data.tar.gz: 8256ef14714ce68534054e91cfce80ee325d5d37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bafd27e6d32f98977fbf35de10c78199c2af622b0130d5c4165cd292419dfd5438aacad180b92d5ed5f2975d6ed2ab5a4dfd247b5cd26b348cdf30ae0dc10b8f
|
7
|
+
data.tar.gz: 51d756276a046a0a0c480b12bdbb9cc5f6516135c92698e28455dd2372b97fbaae792e7be2625bb2a4bb9a47b21454a45dfc96e6d91ac8224bebe5e9d5461e12
|
data/CHANGELOG.md
CHANGED
data/easymongo.gemspec
CHANGED
data/lib/easymongo.rb
CHANGED
@@ -2,8 +2,7 @@ require 'mongo'
|
|
2
2
|
|
3
3
|
module Easymongo
|
4
4
|
|
5
|
-
#
|
6
|
-
# Easymongo MongoDB tiny Ruby library.
|
5
|
+
# Easymongo MongoDB super easy Ruby library.
|
7
6
|
# @homepage: https://github.com/fugroup/easymongo
|
8
7
|
# @author: Vidar <vidar@fugroup.net>, Fugroup Ltd.
|
9
8
|
# @license: MIT, contributions are welcome.
|
data/lib/easymongo/document.rb
CHANGED
@@ -14,6 +14,7 @@ module Easymongo
|
|
14
14
|
|
15
15
|
# Write variables
|
16
16
|
doc.each{|k, v| attr(k, v)}
|
17
|
+
|
17
18
|
end
|
18
19
|
|
19
20
|
# Get bson id
|
@@ -23,7 +24,7 @@ module Easymongo
|
|
23
24
|
|
24
25
|
# Creation date
|
25
26
|
def date
|
26
|
-
bson_id.generation_time
|
27
|
+
bson_id.generation_time rescue nil
|
27
28
|
end
|
28
29
|
|
29
30
|
# Dynamically write value
|
data/lib/easymongo/query.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# This is the easiest possible implementation of a mongodb client.
|
2
2
|
# We got rid of the ObjectID and the underscore, and made mongodb super easy to use.
|
3
|
-
# Use BSON::ObjectId.new.generation_time as timestamp if you need that
|
4
3
|
#
|
5
4
|
# If you need something close to pure Mongo, check out https://github.com/fugroup/minimongo
|
6
5
|
# If you need models for Easymongo, check out https://github.com/fugroup/modelize
|
@@ -23,7 +22,7 @@ module Easymongo
|
|
23
22
|
|
24
23
|
# Set up collection, stored in the thread
|
25
24
|
def method_missing(name, *args, &block)
|
26
|
-
s[:coll] = name; self
|
25
|
+
c!; s[:coll] = name; self
|
27
26
|
end
|
28
27
|
|
29
28
|
# Set values
|
@@ -44,7 +43,7 @@ module Easymongo
|
|
44
43
|
result = client[coll].update_one(data, options, :upsert => true)
|
45
44
|
|
46
45
|
# Return result
|
47
|
-
Easymongo::Result.new(result
|
46
|
+
Easymongo::Result.new(result)
|
48
47
|
end
|
49
48
|
|
50
49
|
# Get values, store cursor in thread
|
@@ -92,7 +91,7 @@ module Easymongo
|
|
92
91
|
result = client[coll].delete_one(data)
|
93
92
|
|
94
93
|
# Return result
|
95
|
-
Easymongo::Result.new(result
|
94
|
+
Easymongo::Result.new(result).tap{ c!}
|
96
95
|
end
|
97
96
|
|
98
97
|
# Make sure data is optimal
|
data/lib/easymongo/result.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
module Easymongo
|
2
2
|
class Result
|
3
3
|
|
4
|
-
|
4
|
+
attr_reader :result
|
5
5
|
|
6
6
|
# Init takes a Mongo::Operation::Result
|
7
|
-
def initialize(result
|
8
|
-
|
9
|
-
self.data = data
|
10
|
-
self.values = values
|
11
|
-
self.options = options
|
7
|
+
def initialize(result)
|
8
|
+
@result = result
|
12
9
|
end
|
13
10
|
|
14
11
|
# Get the id as BSON::ObjectId
|
15
12
|
def bson_id
|
16
|
-
result.upserted_id
|
13
|
+
result.upserted_id rescue nil
|
17
14
|
end
|
18
15
|
|
19
16
|
# Get the id if available
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.6.
|
106
|
+
rubygems_version: 2.6.12
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Super Easy MongoDB client
|