mongoose列表查询,怎么查询出每一条数据是否被当前用户点赞?
{
_id: ObjectId(7df78ad8902c)
title: 'MongoDB Overview',
likes: [ObjectId(7df78ad8902c)]
},
{
_id: ObjectId(7df78ad8902d)
title: 'NoSQL Overview',
likes: [ObjectId(7df78ad8902c)]
},
{
_id: ObjectId(7df78ad8902e)
title: 'Neo4j Overview',
likes: [ObjectId(7df78ad8902c),ObjectId(7df78ad8902c)],
},
这是我的数据结构.moogose怎么实现当前用户是否点赞?并且计算出点赞数量
我想要的结束结果
{
_id: ObjectId(7df78ad8902c)
title: 'MongoDB Overview',
likesNum: 1,
isLike:true
},
{
_id: ObjectId(7df78ad8902d)
title: 'NoSQL Overview',
likesNum: 1,
isLike:true
},
{
_id: ObjectId(7df78ad8902e)
title: 'Neo4j Overview',
likesNum: 2,
isLike:true
},
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…