mongery 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/mongery.rb +11 -0
- data/lib/mongery/version.rb +1 -1
- data/spec/mongery/mapped_properties_spec.rb +4 -0
- 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: f1fddae610fe4e882030d324a292868a29bf4712
|
4
|
+
data.tar.gz: a229e0d6607e12e74dbc126b6b88355a00140583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3ae9814e32674a683b55ccd897cde17e215b845a7685c915e3d6494ef24c5c0749d35501787b4021e887a457ccf57906c0b3bc6df72d6c9c78065324ddaf9d
|
7
|
+
data.tar.gz: b5fe88cf53348315f8a38b1cd6cb29dd7b8f62dca97c79a7bbca7db4245f2ac66994a20b0a737dc19e2e3750ced33cd3b0df02b1374530e91ce296f731612a3b
|
data/CHANGELOG.md
CHANGED
data/lib/mongery.rb
CHANGED
@@ -28,6 +28,10 @@ module Mongery
|
|
28
28
|
build_query.where(*args)
|
29
29
|
end
|
30
30
|
|
31
|
+
def count(*args)
|
32
|
+
build_query.where(*args).count
|
33
|
+
end
|
34
|
+
|
31
35
|
def insert(*args)
|
32
36
|
build_query.insert(*args)
|
33
37
|
end
|
@@ -115,6 +119,13 @@ module Mongery
|
|
115
119
|
end
|
116
120
|
private :mapped_values
|
117
121
|
|
122
|
+
|
123
|
+
def count
|
124
|
+
table.project('COUNT(*)').tap do |t|
|
125
|
+
t.where(condition) if condition
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
118
129
|
def insert(args)
|
119
130
|
Arel::InsertManager.new(table.engine).tap do |manager|
|
120
131
|
manager.into(table)
|
data/lib/mongery/version.rb
CHANGED
@@ -38,6 +38,10 @@ describe "#mapped_properties" do
|
|
38
38
|
.to match /WHERE "test"\."created_at" IN \('2014-01-01', '2015-01-01'\) AND data#>>'{foo}' = 'bar'/;
|
39
39
|
end
|
40
40
|
|
41
|
+
it 'counts WHERE' do
|
42
|
+
expect(builder.count(user_id: '2').to_sql).to match /SELECT COUNT\(\*\).*WHERE "test"."user_id" = '2'/
|
43
|
+
end
|
44
|
+
|
41
45
|
it 'does custom operators' do
|
42
46
|
expect(builder.find(user_id: { "$as" => 2 }).to_sql)
|
43
47
|
.to match /WHERE "test"\."user_id" = 2/;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuhiko Miyagawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arel
|