This is a document for a YouTube-like site. This would be for a channel.
{
_id: "1234",
username: 'corvid',
playlists: [{
name: 'Learn to Develop Meteor',
slug: 'learn-to-develop-meteor-345',
videos: [{
title: 'Publications and Subscriptions',
description: 'Publish and subscribe data from the server',
slug: 'publications-and-subscriptions'
}, {
title: 'Observable collections',
description: 'Observe a live query as it changes',
slug: 'observable-collections'
}]
}, {
name: "Let's play Assassin's Creed: Black Flag",
slug: 'assassins-creed-black-flag-123',
videos: [{
title: 'Part I: You are a pirate!',
description: 'What shall we do with a drunken sailor?'
}]
}]
}
Now here’s the problem: Let’s say you want to publish a single video from this document.
Channels.find({
username: 'corvid',
'playlists.videos.title': 'Publications and Subscriptions'
}, {
fields: { 'playlists.$.videos.$': 1 }
});
This always fails, but how are you supposed to get around it?