mongrep 0.2.0 → 0.2.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/.rubocop.yml +3 -0
- data/.travis.yml +2 -0
- data/README.md +1 -1
- data/lib/mongrep/query.rb +10 -1
- data/lib/mongrep/query_result.rb +13 -2
- data/lib/mongrep/version.rb +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: e5213c7c449784c621feca34ded1df39c9b91dc2
|
4
|
+
data.tar.gz: 1250f6b7535011f3a4e2c5627dae1fc8be128928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d288ca4f5d697ae1c439de27020239f402ae85858ef77ea55ae82c58b5287a77a8e400f73403be961dc05750e84537c2ad4012c7f2aa27d2a8b6ce989f8d486
|
7
|
+
data.tar.gz: 2d4f527de3dbf265920709f3ca8eeb00575bed19f88377d0fff939e6aba6143d42b195708eec96d99f4489e73554aeeee27666ee68cbf7a858c418b70a625d4d
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/lib/mongrep/query.rb
CHANGED
@@ -60,7 +60,16 @@ module Mongrep
|
|
60
60
|
self | self.class.new(query_hash)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
# Combines self with the given query hash by using the MongoDB $and
|
64
|
+
# operator
|
65
|
+
# @param query_hash [Hash] The query hash to combine with the query
|
66
|
+
# @return [Query] A new Query resulting in the combination of the
|
67
|
+
# given query hash and the existing one
|
68
|
+
# @example
|
69
|
+
# query.where(foo: { bar: 'foo' }).and(foo: { foo: 'bar' })
|
70
|
+
def and(query_hash)
|
71
|
+
self.class.new(:$and => [@query_hash, query_hash])
|
72
|
+
end
|
64
73
|
|
65
74
|
# @return [Hash] The underlying query hash
|
66
75
|
def to_h
|
data/lib/mongrep/query_result.rb
CHANGED
@@ -29,6 +29,13 @@ module Mongrep
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
# @return [Integer] The amount of documents in this result
|
33
|
+
def count
|
34
|
+
@collection_view.count
|
35
|
+
ensure
|
36
|
+
@collection_view.close_query
|
37
|
+
end
|
38
|
+
|
32
39
|
# Iterates over the query result
|
33
40
|
# @yieldparam item [Model] A model representing a document from the
|
34
41
|
# query result
|
@@ -36,8 +43,12 @@ module Mongrep
|
|
36
43
|
def each
|
37
44
|
return enum_for(:each) unless block_given?
|
38
45
|
|
39
|
-
|
40
|
-
|
46
|
+
begin
|
47
|
+
@collection_view.each do |document|
|
48
|
+
yield @model_class.new(document)
|
49
|
+
end
|
50
|
+
ensure
|
51
|
+
@collection_view.close_query
|
41
52
|
end
|
42
53
|
end
|
43
54
|
end
|
data/lib/mongrep/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongrep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Reinert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|