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 +4 -4
- data/README.md +1 -1
- data/lib/mongoid_auto_increment_id.rb +12 -5
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9838a8e9fa6948839fb6955fbe07de1c8f1ecd8d
|
4
|
+
data.tar.gz: d05110d3c88b26ee9d65b720cc11b12d4f4a68b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7122409c656ef8bd8e017410b97f28e261ef571e2e136d9fc96aa5ca96e2a890bec62684c3928912b733792c2b0e8443de7690ce5ae7f3d05a356a94e64dce6
|
7
|
+
data.tar.gz: 04d3a42419a62788c441bab05780703219726ec5f96338c9f50384ce1e5cc62060a0d76effc9af4539cb6c49def71e39eee6ac6df4e55e00e7924b42d8b1edd9
|
data/README.md
CHANGED
@@ -2,11 +2,18 @@ module Mongoid
|
|
2
2
|
class Identity
|
3
3
|
# Generate auto increment id
|
4
4
|
def self.generate_id(document)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
+
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
|
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:
|