hashy_db 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hashy_db/data_store.rb +4 -0
- data/lib/hashy_db/version.rb +1 -1
- data/spec/lib/data_store_spec.rb +6 -0
- metadata +2 -2
data/lib/hashy_db/data_store.rb
CHANGED
@@ -41,6 +41,10 @@ module HashyDb
|
|
41
41
|
find(collection_name, :id, primary_key_value)[field_name] = new_value
|
42
42
|
end
|
43
43
|
|
44
|
+
def increment_field_by_amount(collection_name, primary_key_value, field_name, amount)
|
45
|
+
find(collection_name, :id, primary_key_value)[field_name] += amount
|
46
|
+
end
|
47
|
+
|
44
48
|
def get_all_for_key_with_value(collection_name, key, value)
|
45
49
|
find_all(collection_name).select { |a| a[key] == value }
|
46
50
|
end
|
data/lib/hashy_db/version.rb
CHANGED
data/spec/lib/data_store_spec.rb
CHANGED
@@ -78,6 +78,12 @@ describe HashyDb::DataStore do
|
|
78
78
|
subject.find(:some_collection, :id, 3)[:field_2].should == '10'
|
79
79
|
end
|
80
80
|
|
81
|
+
it 'can increment a field with a given amount for a specific field' do
|
82
|
+
subject.increment_field_by_amount(:some_collection, 1, :field_2, 3)
|
83
|
+
|
84
|
+
subject.find(:some_collection, :id, 1)[:field_2].should == 6
|
85
|
+
end
|
86
|
+
|
81
87
|
it 'can get one document' do
|
82
88
|
subject.find(:some_collection, :field_1, 'value 1').should == data1
|
83
89
|
subject.find(:some_collection, :field_2, 6).should == data2
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashy_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-08-
|
14
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|