I have a very strange situation with a couple of meteor applications that I am running on a semi-production machine.
Basically, I have a few documents (I'm actually not sure how many at the moment) that have duplicate fields:
{
"_id" : ObjectId("5006040239bcf91fab6311e5"),
"first_name" : "First Name",
"landline" : "555 555-5555",
"last_name" : "Last Name",
"prior_email" : "newrandomemail@example.net",
"prior_email" : "newrandomemail@example.net",
}
The mongo docs are a little vague about the validity of this state:
BSON documents may have more than one field with the same name. Most MongoDB interfaces, however, represent MongoDB with a structure (e.g. a hash table) that does not support duplicate field names. If you need to manipulate documents that have more than one field with the same name, see the driver documentation for your driver.
Some documents created by internal MongoDB processes may have duplicate fields, but no MongoDB process will ever add duplicate fields to an existing user document. http://docs.mongodb.org/manual/core/document/#field-names
I guess there's some argument as to whether or not JSON should ever have duplicate keys: Does JSON syntax allow duplicate keys in an object? but I can't imagine that a javascript (NodeJS, Meteor, etc) driver would ever intentionally do that.
It's a little complicated, though, because we have two Meteor applications sharing a single database. They're basically the front and admin ends of our software. In order to run both of the applications, I start one first with:
meteor -p 3000
Then I start the second with:
export MONGO_URL="mongodb://localhost:3001/meteor"
meteor -p 3002
The strangest thing is that when using the second application, the Meteor findOne() call for that document shows "oldrandomemail@example.net" for the "prior_email" value - the value that had been set previously and then later changed to "newrandomemail@example.net".
I know that these aren't exactly best practices for production deployment, but I'm wondering if anyone else has seen this or has any idea what might be triggering it...
EDIT: The code that updates the database is pretty basic:
Subscribers.update(this._id, {$set: {'prior_email': 'newrandomemail@example.net'}});