MongoDB select where in array of _id?

前端 未结 5 1094
眼角桃花
眼角桃花 2020-11-29 23:59

is possible in mongo db to select collection\'s documents like in SQL :

SELECT * FROM collection WHERE _id IN (1,2,3,4);

or if i have a

5条回答
  •  抹茶落季
    2020-11-30 00:53

    This is not related to mongo query. I was familiar with SQL and used Studio3T IDE to query a mongo database using SQL. If you are one like me, I want to point out that the id value needs to be typecasted. So the query will look like:

    SELECT _id from 
    WHERE _id = ObjectId("5883d387971bb840b7399130");
    

提交回复
热议问题