Class: Mongoid::Sequences

Inherits:
Object
  • Object
show all
Includes:
Document
Defined in:
lib/mongoid-sequence2/sequences.rb

Class Method Summary collapse

Class Method Details

.get_next_sequence(collection, fieldname) ⇒ Object



10
11
12
13
# File 'lib/mongoid-sequence2/sequences.rb', line 10

def self.get_next_sequence(collection, fieldname)
  #Sequences.where(fieldname: "#{collection}_#{fieldname}").find_and_modify({'$inc' => {'seq' => 1}}, {'upsert' => 'true', :new => true}).seq
  self.where(fieldname: "#{collection}_#{fieldname}").find_and_modify({'$inc' => {'seq' => 1}}, {'upsert' => 'true', :new => true}).seq
end