// Switch to database test1 use test1; // List all users db.users.find(); // Find the users whose first names are John db.users.find( { firstName: 'John' } ); // Find the first names of the users whose last names are Doe db.users.find( { lastName: 'Doe' }, { firstName: true } ); // Find the users who are older than 20 db.users.find( { age: { $gt: 20 } } ); // Find the users who are older than 20 and younger than 30 db.users.find( { age: { $gt: 20, $lt: 30 } } ); // Find the users who are younger than 20 or older than 30 db.users.find( { $or: [ {age: {$lt: 20}}, {age: {$gt: 30}} ] } ); // Find the users who in CA db.users.find( { 'address.state' : 'CA' } );