MongoLab _id field

I am running into a strange problem, where we are using MongoDB on our local development environment and MongoLabs on Heroku for our production environment. Now the problem comes with the way MongoLabs handles _id field. Instead of doing _id: '0x....' it is using _id: { $oid: '0x...'}.

This seems to be causing some problems, as some code does not work as expected on production but works perfectly on our local machines.

We are using Nodes.js with Mongoose and Express for this project. I noticed the problem when it gave me undefined for model._id.

Is there a way to force the two to be consistent? preferably force MongoLab to use _id: '0x...'?

Update: I manage to figure out why I was getting undefined id. We were just using cwd() to require some modules and ended up requiring a different module with a similar name since the cwd we run the production build is a little different than the dev build.

But I would still like to know why MongoLabs uses that variant of the id and how it still works despite that.

I ran into the problem

If I stay within php there no problem using the I'd as is.

But if I move from an array to json to array, it does not work.