MongoDB not returning object properties in array on document

Asked this over on StackOverflow but everyone there was as puzzled as I was. Wanted to see if anyone here might know the answer!

Using MeteorJS, I have a MongoDB collection where each document has an address field that is an array of objects. Here’s how it looks in the db:

{
  "_id" : "eEzHuNCHPPGNLo2mp",
  "addresses" : [
	{
	  "type" : "Dropoff",
	  "street" : "123 MAIN ST",
	  "street2" : "",
	  "city" : "ANYTOWN",
	  "state" : "ST",
	  "zip" : "12345-6789",
	  "country" : "US",
	  "loc" : {
	    "type" : "Point",
		"coordinates" : [
		  -100.100100,
		  30.303030
		]
	  }
    }
  ]
}

When I go to the command line and try db.docs.find({_id: 'eEzHuNCHPPGNLo2mp' },{ 'addresses': 1 }); I get that exact output.

Here’s how I would find the same document via Meteor’s Mongo implementation:

    var docs = Docs.find(
                  { '_id': 'eEzHuNCHPPGNLo2mp' },
                  { fields: { 'addresses': 1 } }
                ).fetch();

When I do that though, the document comes back as:

[{
  type: 'Dropoff',
  street: '123 MAIN ST',
  city: 'ANYTOWN',
  state: 'ST',
  zip: '12345-6789',
  country: 'US'
}]

Both the street2 and loc properties have been dropped.

Even if I ask for each property specifically, it will not return them.

I’ve tried find() and findOne() with the same results.

I’m doing this on the server, not the client, so there’s no issue with published data.

To make this more weird, I tried it without the projection and while I got back every field in the collection, the addresses array still has those fields cut off.

Finally, this happens with all items, not just a single item.

Any ideas?

I just copied and pasted your object into a small meteor app with an insert followed by a matching findOne and it worked correctly.

Are you certain that your Docs collection inside Meteor is your contacts collection in Mongo (do you have a Docs = new Mongo.Collection('contacts') somewhere in your code)?

@robfallows, thanks for taking a look. That’s what’s so weird – it works just fine everywhere else. I can even get these other fields to display on the client just fine.

Sorry about the db.contacts.find(). I switched everything to “docs” for the sake of simplicity in posting the question. I’ve updated the code above.

I think if you’re able to get the data in the mongo shell, then that would say to me that there is a package, etc. that is filtering your results. Though it would have to be done at the collection level?

Looking at that particular doc, you see that the street2 and loc properties are the only ones that aren’t populated string values. If you switch the values of street2 and street, do you see different fields come back?