Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 576 Bytes

README.rdoc

File metadata and controls

30 lines (21 loc) · 576 Bytes

MongoMapper AutoIncrement

Installation

script/plugin install git://github.com/voraz/mongo-autoincrement.git

Usage

class Order
  include MongoMapper::Document
  include MongoAutoincrement

  has_autoincrement :code, :zerofill=>10
end

> order = Order.new
 => #<Order _id: 4b744d47421aa95b91000001, code: nil>
> order.save
 => true
> order.code
 => "0000000008"

> order2 = Order.new
 => #<Order _id: 4b744d79421aa95b91000002, code: nil>
> order2.save
 => true
> order2.code
 => "0000000009"