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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe6385d3fabb1f17ebd5637f248fab8b776d7718
4
- data.tar.gz: 1acfe3b40ce8de1d187fa43b7ad4277cc6cf534e
3
+ metadata.gz: f1fddae610fe4e882030d324a292868a29bf4712
4
+ data.tar.gz: a229e0d6607e12e74dbc126b6b88355a00140583
5
5
  SHA512:
6
- metadata.gz: 21a99f928bd828a80391a10d90a0db8c8bd2401cebc8538df8d5d309fddd5d4bddd96c870bb3c99a1464a59889c786887aad59536f67bbf042c96f6bcf47bde6
7
- data.tar.gz: bb095b44a1482056496e3a209169f27f3d6c255f621717d065a9be4132cd060281723f8f390dd1368420010d32ca6fb5c049d1f6fd1681fdd53c22a9a8e6ead9
6
+ metadata.gz: 9f3ae9814e32674a683b55ccd897cde17e215b845a7685c915e3d6494ef24c5c0749d35501787b4021e887a457ccf57906c0b3bc6df72d6c9c78065324ddaf9d
7
+ data.tar.gz: b5fe88cf53348315f8a38b1cd6cb29dd7b8f62dca97c79a7bbca7db4245f2ac66994a20b0a737dc19e2e3750ced33cd3b0df02b1374530e91ce296f731612a3b
@@ -1,3 +1,6 @@
1
+ ## 1.0.5 (2015/02/02)
2
+ - Added #count (gfx)
3
+
1
4
  ## 1.0.4 (2015/01/19)
2
5
  - Support custom operators
3
6
 
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Mongery
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -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
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-01-20 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arel