Search with same key in mongoDB

I'm new in mongoDB and I want find a specific users in my collection

In this case I want users with these roles

This is my script

db.users.aggregate(
        { $match : 
            {
                'role.name': 'Elite',
                'role.name': 'SuperElite',                
             } 
        }
);

This query in my mongoDB works, but I can't create an object javascript like:

var query_obj = {'role.name': 'Elite','role.name': 'SuperElite'}

I try also

db.users.aggregate(
        { $match : 
            {
                'role.name': ['Elite','SuperElite']        
             } 
        }
);

but doesn't works

Answers


You can try like this:

db.users.aggregate(
        { $match : 
            {
                'role.name':  {$in: ['Elite','SuperElite']   }     
             } 
        }
);

Need Your Help

JavaScript will not calculate and input my results back into my form

javascript html forms input

Trying to pull information from my form input fields and calculate them using JavaScript. It does not seem to be working.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.