I want to migrate from MySQL to MongoDB.
In MySQL, PKs are integer. I want to cast them into ObjectID
When I try:
mongo.ObjectID(theInteger)
altough theInteger is same, results are different.
How can I do that?
I want to migrate from MySQL to MongoDB.
In MySQL, PKs are integer. I want to cast them into ObjectID
When I try:
mongo.ObjectID(theInteger)
altough theInteger is same, results are different.
How can I do that?
ObjectId
is a hexadecimal, 24-byte chars type from MongoDB. In other words, you can't cast from a int.
The best you could do to maintain your MySQL data structure is use your MySQL PK in _id
field, you'll have no trouble with this.
ObjectId is a special type of mongodb, but if you just want to migrate, you can store integer id of mysql to mongodb's '_id'.