0.0.1 • Published 9 years ago
object-id-with-time v0.0.1
Create ObjectId (mongodb) with specific timestamp
This is mainly useful for faking data
The mongodb package has a function for creating Object Id's with a specific timestamp as well, but it fills the rest with zeroes which is impractical for creating sample data.
var ObjectId = require('mongodb').ObjectId;
var objectIdWithTime = require('objectIdWithTime');
ObjectId.createFromTime(Date('2015-09-20T15:20:17Z')/1000); // ObjectId('55feceb10000000000000000')
objectIdWithTime(Date('2015-09-20T15:20:17Z')); // ObjectId('55feceb10692accd3612ca31')
0.0.1
9 years ago