[英]How can i search for a value inside an object with using findOne in Mongodb
this is my MongoDB data这是我的 MongoDB 数据
an I have to get the token->token data我必须获取令牌->令牌数据
const doc = JSON.parse(reqTest);
const database = client.db("loginapi");
const movies = database.collection("users");
const finder=await movies.findOne({token:{token:doc.token}});
I tried to use this but it didn't work.我尝试使用它,但它没有用。
Since token
is an Object in your document, you have to use 'token.token' to match the strings.由于
token
是文档中的 Object,因此您必须使用“token.token”来匹配字符串。
movies.findOne({ 'token.token': doc.token })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.