javascript - Mongodb: check value equality in any document -


i have form on site users can enter number subnum field. when user submits form, want check if value they've entered exists value in existing document. done in javascript/meteor

all form data gets put object this:

participantobject = {   subnum: parseint(number) } 

this object gets inserted document participants collection

when submit button clicked, need check whether number they've entered has been entered (i.e. exists value subnum in document). if so, prevent form submit , show error

i'm trying check this:

var existingsubs = participants.find(   {subnum: {$eq: participantobject.subnum}} ).count();  console.log(existingsubs); 

i hoping above find me documents subnum equal value entered (participantobject.subnum), , console log count of number of matching documents

the problem in console log see unrecognized operator: $eq

am using equality operator incorrectly?

is there more efficient way perform check this?

you can omit $eq operator:

var existingsubs = participants.find(     {subnum: participantobject.subnum} ).count(); 

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -