我有一个yii2 mongodb的集合,看起来像这样:
{
"_id" : "123",
"books" : [
{
"author" : "John",
"title" : "The Book"
},
{
"author" : "Smith",
"title" : "Something!"
}
]
}
{
"_id" : "321",
"books" : [
{
"author" : "John",
"title" : "The Book"
}
]
}
...
我想得到一个所有书籍的数组(基本上是一个数组数组):
[
{
"author" : "John",
"title" : "The Book"
},
{
"author" : "Smith",
"title" : "Something!"
},
{
"author" : "John",
"title" : "The Book"
}
...
]
我看到了封闭式问题的答案,但它们都取得了一些不同的结果。
也试过
$collection->distinct('books', [], [])
它起作用了,但它删除了不可接受的副本。