Skip to content

Instantly share code, notes, and snippets.

@ozgun
Last active December 11, 2015 15:29
Show Gist options
  • Select an option

  • Save ozgun/4621154 to your computer and use it in GitHub Desktop.

Select an option

Save ozgun/4621154 to your computer and use it in GitHub Desktop.
Generating timestamps with mongo Ruby driver (Ruby code)
# encoding: utf-8
require 'json'
require 'mongo'
@conn = Mongo::Connection.new("localhost", 27017, safe: true)
@db = @conn['timestamp_test']
@coll = @db['test_col']
@coll.save({a: BSON::Timestamp.new(4294967295, 4294967295)})
@coll.find.first["a"].seconds # => 4294967295
@coll.find.first["a"].increment # => 4294967295
# mongo shell
# > db.test_col.find()
# { "_id" : ObjectId("51012a6d8d74494bd8000001"), "a" : Timestamp(4294967295000, 4294967295) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment