“Descansar a MongoDB” Código de respuesta

MongoDB relajarse

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

Descansar a 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

Descansar a MongoDB

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

Respuestas similares a “Descansar a MongoDB”

Preguntas similares a “Descansar a MongoDB”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código