rasti-db 0.2.4 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c12a313c4f6a804f756dd54cb07faa290a5901e
4
- data.tar.gz: 0f2e3fe0233fe829ff370e8150eb85c5cdfe44a7
3
+ metadata.gz: 68eec068751c890730dc3399cd37d5903ba6ec82
4
+ data.tar.gz: 8fa04f6ffd482270decf4b329075f22b1effc068
5
5
  SHA512:
6
- metadata.gz: 1efd610058a919b812f6051e067c432b3179e853ba18625c47f4b5b5b4ca7a875d42428a8ac8afefc7135bf97d4be11757c81d51f6d0778409571609f8928ca1
7
- data.tar.gz: 040e78c5470f454bca8ca10ddc75629e228a03e62e703ea849b5cb8b81de70feebb0878e598b925d147b15ba3fa2b97e8174c867bd6a5754453de90a73f55607
6
+ metadata.gz: beaf88832aa2d2077fc9c9ad61383bacebf84aeb21830cc965896d97fed3ad720482acd6cfd4a98a8369c58501702cdce5cc2d7865963660dad58c5cba531733
7
+ data.tar.gz: aa887838a3da061324e1f4d782f15a7fbf2ef5e327176ac7c92d7d51bec45269070cac3d24fe0a57d8d1b930569a0069a0ee036113a1f9addc4dfc56c8d59189
@@ -2,7 +2,7 @@ module Rasti
2
2
  module DB
3
3
  class Collection
4
4
 
5
- QUERY_METHODS = (Query::DATASET_CHAINED_METHODS + [:graph, :count, :all, :first]).freeze
5
+ QUERY_METHODS = (Query::DATASET_CHAINED_METHODS + [:graph, :count, :all, :first, :pluck, :primary_keys, :any?, :empty?, :raw]).freeze
6
6
 
7
7
  include Helpers::WithSchema
8
8
 
@@ -177,7 +177,7 @@ module Rasti
177
177
  end
178
178
 
179
179
  def exists?(filter=nil, &block)
180
- build_query(filter, &block).count > 0
180
+ build_query(filter, &block).any?
181
181
  end
182
182
 
183
183
  def detect(filter=nil, &block)
@@ -76,6 +76,10 @@ module Rasti
76
76
  row ? collection_class.model.new(with_relations(row)) : nil
77
77
  end
78
78
 
79
+ def detect(*args, &block)
80
+ where(*args, &block).first
81
+ end
82
+
79
83
  def to_s
80
84
  "#<#{self.class.name}: \"#{dataset.sql}\">"
81
85
  end
@@ -1,5 +1,5 @@
1
1
  module Rasti
2
2
  module DB
3
- VERSION = '0.2.4'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  end
data/spec/query_spec.rb CHANGED
@@ -40,6 +40,10 @@ describe 'Query' do
40
40
  users_query.map { |u| u.name }.must_equal db[:users].map(:name)
41
41
  end
42
42
 
43
+ it 'Detect' do
44
+ users_query.detect(id: 3).must_equal User.new(id: 3, name: 'User 3')
45
+ end
46
+
43
47
  it 'Where' do
44
48
  users_query.where(id: 3).all.must_equal [User.new(id: 3, name: 'User 3')]
45
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasti-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2017-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel