javascript - How to compare two fields in mongoDB? -


i have problem meteor, display groups slider. when click on group display users.

i want display users belong group admin, in group admin , users manager on groups manager etc...

html :

<template name="manage">     {{> header}}      <div class="menu">        <div class="accordion">           <div class="accordion-group">           {{#each roles}} <div class="accordion-heading country">             <!-- <img src="http://placehold.it/100x30" alt="country flag" style="float:left; margin: 3px 10px 0 3px; text-align:center;"/> -->             <p style="border: 1px solid grey; border-radius: 5px; font-weight: bold; width: 100px; height :30px; float:left; margin: 3px 10px 0 3px; text-align:center;">{{name}}</p>       <a class="accordion-toggle" data-toggle="collapse" href="#country{{_id}}">{{pays}} - {{lieu}} - {{increment}}</a>     </div>     <div id="country{{_id}}" class="accordion-body collapse">       <div class="accordion-inner">         <table class="table table-striped table-condensed">           <thead>             <tr>               <th>utilisateurs</th>               <th>nom</th>               <th>prenom</th>               <th>statut</th>               <th>id</th>             </tr>           </thead>              <tbody>           {{#each users "1"}}           <!-- {{#if roles "lol"}} -->             <tr>               {{#each emails}}               <td>{{address}}</td>               {{/each}}               <td>{{profile.name}}</td>               <td>{{profile.name}}</td>               <td>ok</td>               <td>{{increment}}</td>             </tr>             <!-- {{/if}} -->           {{/each}}           </tbody>         </table>       </div>     </div>    {{/each}}   </div> </div> 

js :

template.manage.roles = function () {     return meteor.roles.find(); };   template.manage.users = function (inc) {    return meteor.users.find({increment : inc}); }; 

so, i'm trying compare 2 fields in db have better solution ? sorry, i'm new meteor :)

one way go it, store selected group in session , have meteor.users.find() react session variable. session in meteor inherently reactive.

example:

<template name="manage">   <button class="role" value="manager">manager</button>   {{#each users}}     {{name}}   {{/each}} </template>  template.manage.events({   'click .role': function(event, template) {     session.set('role', event.target.value);   } });  template.manage.helpers({   users: function() {     return meteor.users.find({role: session.get('role')});   } }); 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -