db.book.aggregate([

{

$match:{

sign_status: "xfinish"

}

},{

$lookup: {

from: "user",

localField: "user_id",

foreignField: "_id",

as: "user"

}

},

{

$lookup: {

from: "chapter",

localField: "_id",

foreignField: "book_id",

as: "chapter"

}

}

,

{

$unwind:{

path:"$chapter",

preserveNullAndEmptyArrays: true,

}

},

{

$group:{

_id:{id:"$_id",name:"$name",chpater_book:"$chapter.book_id",penname:"$user.penname",username:"$user.name",signType:"$sign_type",attribute:"$attribute",finish_time:"$finish_time",wordCont:"$word_count"},

count2:{$sum:1}

}

}

]

)

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐