“desenrolar MongoDB” Respostas de código

MongoDB desenrolando

{
  $unwind:
    {
      path: <field path>,
      includeArrayIndex: <string>,
      // to include documents whose sizes field is null, missing, or an empty array.
      preserveNullAndEmptyArrays: <boolean>
    }
}
North Bear

desenrolar MongoDB

unwind:
 It is used for array attribute to show seprate result for that array.

// Inserted data : 
db.inventory.insertOne({ "_id" : 1, "item" : "ABC1", 
sizes: [ "S", "M", "L"] })

// unwind query 
db.inventory.aggregate( [ { $unwind : "$sizes" } ] )

// output
{ "_id" : 1, "item" : "ABC1", "sizes" : "S" }
{ "_id" : 1, "item" : "ABC1", "sizes" : "M" }
{ "_id" : 1, "item" : "ABC1", "sizes" : "L" }
Abhishek

Desenrolar MongoDB

db.vehicledetails.aggregate([{$unwind : {path: "$model_year", preserveNullAndEmptyArrays: true}}]).pretty()
Important Ibis

Respostas semelhantes a “desenrolar MongoDB”

Perguntas semelhantes a “desenrolar MongoDB”

Procure respostas de código populares por idioma

Procurar outros idiomas de código