Last active
December 11, 2015 15:29
-
-
Save ozgun/4621154 to your computer and use it in GitHub Desktop.
Generating timestamps with mongo Ruby driver (Ruby code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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