Querying Mongo documents for array properties

Ladies and gents, I’m just posting one short reminder to myself and anyone keen to find out how do we query array type fields in mongodb.

Let’s start by inserting couple of documents (using mongodb shell) which we’ll use for querying afterwards:

db.developers.insertMany([
    { "name" : "John", "languages" : ["java", "php", "javascript"] },
    { "name" : "Jack", "languages" : ["java", "c", "c++"] },
    { "name" : "Jim", "languages" : ["node", "java"] }
]);

Continue reading