Search⌘ K
AI Features

Solution: Reading Arrays

We'll cover the following...
Query
db.products.find(
{
tags: { $elemMatch: { $regex: /\busb\b/i } }
},
{
name: 1,
category: 1,
tags: 1,
_id: 0
}
)

The explanation of the query is given below:

  • Line 1: This begins a query on the products collection using the find() method. This tells MongoDB that we want to ...