javascript - Mongo DB findOne with multiple arguments - Stack Overflow

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

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})

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745584884a4634474.html

相关推荐

  • javascript - Mongo DB findOne with multiple arguments - Stack Overflow

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

    9小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信