mongodb_qrc_queries.pdf - MongoDB Reference Card Queries...

  • No School
  • AA 1
  • 2

This preview shows page 1 - 2 out of 2 pages.

{a: 10} Docs where a is 10 , or an array containing the value 10 . {a: 10, b: "hello"} Docs where a is 10 and b is "hello" . {a: {$gt: 10}} Docs where a is greater than 10 . Also available: $lt (<), $gte (>=) , $lte (<=) , and $ne (!=) . {a: {$in: [10, "hello"]}} Docs where a is either 10 or "hello" . {a: {$all: [10, "hello"]}} Docs where a is an array containing both 10 and "hello" . {"a.b": 10} Docs where a is an embedded document with b equal to 10 . {a: {$elemMatch: {b: 1, c: 2}}} Docs where a is an array that contains an element with both b equal to 1 and c equal to 2 . {$or: [{a: 1}, {b: 2}]} Docs where a is 1 or b is 2 . {a: /^m/} Docs where a begins with the letter m . {a: {$mod: [10, 1]}} Docs where a mod 10 is 1 . {a: {$type: 2}} Docs where a is a string (see bsonspec.org for more). Queries and What They Match {a: {$nin: [10, "hello"]}} Docs where a is anything but 10 or "hello" . {a: {$size: 3}} Docs where a is an array with exactly 3 elements. {a: {$exists: true}} Docs containing an a field. {a: /foo.*bar/} Docs where a matches the regular expression foo.*bar . {a: {$not: {$type: 2}}} Docs where a is not a string. $not negates any of the other query operators. The following queries cannot use indexes as of MongoDB v2.0. These query forms should normally be
Image of page 1

Subscribe to view the full document.

Image of page 2
  • Fall '19
  • Equals sign, ASCII, Query language, MongoDB v2.0

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes