MBiff
2013-01-17 02:39:34 UTC
I have to import a lot of data into MongoDB from MySQL and I'd like to use
the timestamp from the ObjectID instead of storing it in a separate
key/value (as it is in the existing data). In order to do this I'd need to
create an ObjectID for the existing data with a date from the past. I also
need to do this using the PHP driver. It seems like maybe there is a way to
do this in Python, Java and Node.JS so I thought maybe there was an
equivalent method in PHP.
If this is possible - is it safe to do? Meaning and I going to have issues
with duplicate or invalid ObjectIDs? Thanks.
In Python (this is maybe only for doing queries?):
gen_time = datetime.datetime(2010, 1, 1)
dummy_id = ObjectId.from_datetime(gen_time)
In Java:
Date d = new Date(some timestamp in ms);
ObjectId id = new ObjectId(d)
In node
var timestamp = Math.floor(new Date().getTime()/1000);
var objectId = new ObjectID(timestamp);
the timestamp from the ObjectID instead of storing it in a separate
key/value (as it is in the existing data). In order to do this I'd need to
create an ObjectID for the existing data with a date from the past. I also
need to do this using the PHP driver. It seems like maybe there is a way to
do this in Python, Java and Node.JS so I thought maybe there was an
equivalent method in PHP.
If this is possible - is it safe to do? Meaning and I going to have issues
with duplicate or invalid ObjectIDs? Thanks.
In Python (this is maybe only for doing queries?):
gen_time = datetime.datetime(2010, 1, 1)
dummy_id = ObjectId.from_datetime(gen_time)
In Java:
Date d = new Date(some timestamp in ms);
ObjectId id = new ObjectId(d)
In node
var timestamp = Math.floor(new Date().getTime()/1000);
var objectId = new ObjectID(timestamp);
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb