mongoid_auto_increment_id 0.6.4 → 0.6.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: 449618cc87c1c15cb4a4687c16ab0fbfa0f0b329
4
- data.tar.gz: 0543aa1040bb9d5779741d1af69b7eb6fdc14398
3
+ metadata.gz: 9838a8e9fa6948839fb6955fbe07de1c8f1ecd8d
4
+ data.tar.gz: d05110d3c88b26ee9d65b720cc11b12d4f4a68b7
5
5
  SHA512:
6
- metadata.gz: 652b684be9f30fc88696f73f7acb9e18864cb95af69b7e2fffa97e87ab6e2797d135dcc79d9c16fc45c368b873983aeab509bbc449481ffb629cd2ee6d95fb00
7
- data.tar.gz: 9c02e0384d385ed420996c7e25e1e5516cc9af8cd445d777139f19809d84639b27d1fa9c91140519827b691cffd36d252c2b41c89a02166fd40b6cae71588571
6
+ metadata.gz: c7122409c656ef8bd8e017410b97f28e261ef571e2e136d9fc96aa5ca96e2a890bec62684c3928912b733792c2b0e8443de7690ce5ae7f3d05a356a94e64dce6
7
+ data.tar.gz: 04d3a42419a62788c441bab05780703219726ec5f96338c9f50384ce1e5cc62060a0d76effc9af4539cb6c49def71e39eee6ac6df4e55e00e7924b42d8b1edd9
data/README.md CHANGED
@@ -17,7 +17,7 @@ gem 'mongoid_auto_increment_id', "0.6.1"
17
17
  gem 'mongoid_auto_increment_id', "0.6.2"
18
18
 
19
19
  # Mongoid 4.0.0+
20
- gem 'mongoid_auto_increment_id', "0.6.4"
20
+ gem 'mongoid_auto_increment_id', "0.6.5"
21
21
  ```
22
22
 
23
23
  ## USAGE
@@ -2,11 +2,18 @@ module Mongoid
2
2
  class Identity
3
3
  # Generate auto increment id
4
4
  def self.generate_id(document)
5
- o = Mongoid::Sessions.default.command({:findAndModify => "mongoid.auto_increment_ids",
6
- :query => { :_id => document.collection_name },
7
- :update => { "$inc" => { :c => 1 } },
8
- :upsert => true,
9
- :new => true })
5
+ database_name = Mongoid::Sessions.default.send(:current_database).name
6
+
7
+ o = nil
8
+ Mongoid::Sessions.default.cluster.with_primary do |node|
9
+ o = node.command(database_name,
10
+ {"findAndModify" => "mongoid.auto_increment_ids",
11
+ :query => { :_id => document.collection_name },
12
+ :update => { "$inc" => { :c => 1 }},
13
+ :upsert => true,
14
+ :new => true }, {})
15
+ end
16
+
10
17
  o["value"]["c"].to_i
11
18
  end
12
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_auto_increment_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -63,4 +63,3 @@ signing_key:
63
63
  specification_version: 4
64
64
  summary: Override id field with MySQL like auto increment for Mongoid
65
65
  test_files: []
66
- has_rdoc: