javascript - meteor collections field search -


i grab selected mongo document using 'this' inside of template.alerts.events function. want check see if current document (this) contains specific field. precise, want see if contains userid store there myself previously.

doc {     field1: 'a'      myfield: {         userid1: timestamp         userid2: timestamp         ...     }  } 

i want see if current user's userid in userid fields of myfield.

i have tried:

var x = this.userid if(this.myfield.x) {     //do } 

and i'm wondering whether because need wrap userid in string or something, can't condition evaluate. have tried using object.hasownproperty didn't work. how can in non query way?

i'm assuming you're trying see if 'x' field in object this.myfield. if so, have this: if (this.myfield[this.userid]). if you're trying compare x , this.myfield, need if (this.userid == this.myfield)


Comments