admin管理员组

文章数量:1431435

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

本文标签: javascriptMongo DB findOne with multiple argumentsStack Overflow