mongodb $not _id

前端 未结 2 921
南笙
南笙 2021-01-17 11:49

I need a way to search but not include an _id which is already on the screen in front of the user. For example, I have 3 pet profiles one which the user is already viewing.<

2条回答
  •  轮回少年
    2021-01-17 12:30

    Use $ne as (notice no need to use ObjectId(), string will autocast to ObjectId):

    db.organizations.find({"_id" : {$ne:"563c50e05cdb2be30391e873"}})
    

提交回复
热议问题