最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Mongo DB findOne with multiple arguments - Stack Overflow

programmeradmin10浏览0评论

I am developing a website using Meteor JS and I need to update records in my database based on a username.

var responseId=userAccounts.findOne({likedPostsId:idToSearch, $where: {username:myUsername}});

Basically I want it to return the documents where the likedPostsId match the searched Id and where the username in the collection is the same as the user that is logged in. I am new to Meteor Mongo so probably my syntax is wrong. I would appreciate some help.

I am developing a website using Meteor JS and I need to update records in my database based on a username.

var responseId=userAccounts.findOne({likedPostsId:idToSearch, $where: {username:myUsername}});

Basically I want it to return the documents where the likedPostsId match the searched Id and where the username in the collection is the same as the user that is logged in. I am new to Meteor Mongo so probably my syntax is wrong. I would appreciate some help.

Share Improve this question asked Jun 19, 2017 at 22:46 Roberto ChirilaRoberto Chirila 1251 silver badge10 bronze badges 1
  • @JohnnyHK Thank you ! It worked ! – Roberto Chirila Commented Jun 19, 2017 at 22:58
Add a ment  | 

1 Answer 1

Reset to default 5

You don't need $where for that and you can simplify it to:

userAccounts.findOne({likedPostsId: idToSearch, username: myUsername})
发布评论

评论列表(0)

  1. 暂无评论