Mongoose findbyid() return null

前端 未结 5 854
时光取名叫无心
时光取名叫无心 2021-01-13 01:04

I am trying to find a record in my mongo db by its id

No matter I use findbyid(), findone(id,...), it return null

here is my code. what is the solution?

5条回答
  •  粉色の甜心
    2021-01-13 01:25

    Check your mongodb database, if _id is storaged as String, findById(id) can not found id. FindById(id) only finds ObjectId('yourId'). You might import database by using mongoimport and including _id in JSON, it's wrong, delete _id in imported JSON.

提交回复
热议问题