Gibt es einen einfachen Weg, um „$ Push“ alle Felder eines Dokuments? Zum Beispiel:Mongo Gruppe und Push: Schieben Sie alle Felder
sagen, dass ich eine Mongo Sammlung der Bücher habe:
{author: "tolstoy", title:"war & peace", price:100, pages:800}
{author: "tolstoy", title:"Ivan Ilyich", price:50, pages:100}
ich sie zu einer Gruppe von Autor möchte - für jeden Autor, listet seine gesamten Objekte Buch:
{ author: "tolstoy",
books: [
{author: "tolstoy", title:"war & peace", price:100, pages:800}
{author: "tolstoy", title:"Ivan Ilyich", price:50, pages:100}
]
}
ich kann dies erreichen, indem er explizit alle Felder drängen:
{$group: {
_id: "$author",
books:{$push: {author:"$author", title:"$title", price:"$price", pages:"$pages"}},
}}
Aber gibt es eine Abkürzung, etwas in den Zeilen:
// Fictional syntax...
{$group: {
_id: "$author",
books:{$push: "$.*"},
}}
Dank
dank viel, sieht, dass es sehr interessant. –