sql >> Base de Datos >  >> NoSQL >> MongoDB

MongoDB obtener subdocumento

Puede hacerlo con Aggregation Framework. La consulta será algo como:

db.customer.aggregate([
    {$unwind : "$channels"},
    {$match : {"channels.id" : "10000-1"}},
    {$project : {_id : 0, 
                 id : "$channels.id", 
                 name : "$channels.name", 
                 enabled : "$channels.enabled"}}
])