This repository is a demonstration that simultaneous subscriptions with different mongo projections for nested fields can lead to unexpected data.
Each item in the Bikes collection has the following structure:
{
"_id": "_id_",
"type": "Type",
"gears": {
"front": "54",
"rear": "16"
},
"color": "Color"
}A list of all bike records is shown. This list has the following subscription with field projection:
Meteor.subscribe('bikes', {}, { fields: { type: 1, 'gears.rear': 1 } })Note that from gears only one nested field will be fetched.
When you click on one list item, a new subscription is started without field projection to get the whole document:
Meteor.subscribe('bikes', _id)All top-level and nested fields are be fetched from the database.
- All top-level fields are fetched, including
colorwhich was not fetched for the list. - The nested fields are subset to the ones specified in the subscription for the list:
gears.frontis not fetched.