32. Querying the Arrays of embedded documents - MongoDB

preview_player
Показать описание
In this video we will see how to query the array of embedded documents - MongoDB

If you like my video, please subscribe to my channel.

Join in the Telegram Group

My Playlists:
Angular CLI Complete Course Tutorial:
Angular UnitTesting Complete Course:

My Courses Playlist Page:

#mongodb #leelawebdev

Join this channel to get access to perks:
Рекомендации по теме
Комментарии
Автор

I wished you talked about elemMatch too and other aspects of querying arrays in mongodb but all in all thanks keep up the good work ❤

sjdms
Автор

HI Leela. This was good. I was searching the content where embedded document can be filtered. My requirement is, in hobbies i want to project only title is matching Sports. could you help me to figure out this. Thanks.

mallikarjunc
Автор

const task = await taskCollection.find({
_id,
'attachments._id': as string),
});

db-accessor:
export const find = async (query = {}, sortOptions = {}): Promise<ITaskCollection[] | null> => {
query);
return db.notaryTaskCollection
.find(query)
.sort(sortOptions)
.catch((err: Error) => {
logger.error(err);
return null; // Return null on error instead of an empty array
});
};


[
{
_id: new ObjectId('6724ce9634f2433de715065a'),
taskName: '',
attachments: [ [Object], [Object], [Object], [Object] ],
createdAt: 2024-11-01T12:50:30.286Z,
updatedAt: 2024-11-01T12:50:30.286Z,
__v: 0
}
]

attachments: [
{
fileName: 'test.pdf',
filePath: '',
uploadDate:,
uploadedBy:,
_id: new ObjectId('6724ce9634f2433de715065b'),
notes: []
},
]

its returing all attachments object, filtering is not working

joshnaj.u