{"id":169010,"date":"2023-10-05T09:23:40","date_gmt":"2023-10-05T09:23:40","guid":{"rendered":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/"},"modified":"2023-10-05T09:23:40","modified_gmt":"2023-10-05T09:23:40","slug":"how-to-find-a-common-value-in-an-array-in-mongodb","status":"publish","type":"post","link":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/","title":{"rendered":"How to find a common value in an array in MongoDB?"},"content":{"rendered":"<p>In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a collection by a specified expression, and in this case, we can group by the array field and use the $push operator to create an array of all values. Once we have an array of all values, we can then find the common value using the $setIntersection operator.<\/p>\n<p><b>Here is the MongoDB aggregation query to find a common value in an array:<\/b><\/p>\n<p>&#8220;`<br \/>\ndb.collection.aggregate([<br \/>\n  { $unwind: &#8220;$arrayField&#8221; },<br \/>\n  { <br \/>\n    $group: {<br \/>\n      _id: null,<br \/>\n      commonValues: { $push: &#8220;$arrayField&#8221; }<br \/>\n    }<br \/>\n  },<br \/>\n  {<br \/>\n    $project: {<br \/>\n      commonValue: {<br \/>\n        $setIntersection: [&#8220;$commonValues&#8221;]<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n])<br \/>\n&#8220;`<\/p>\n<p>This query first unwinds the array field, groups all values from the array into a single array, and then using the $setIntersection operator, finds the common value.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_62 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#1_How_can_I_find_documents_containing_a_specific_value_in_an_array_in_MongoDB\" title=\"1. How can I find documents containing a specific value in an array in MongoDB?\">1. How can I find documents containing a specific value in an array in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#2_Can_I_update_documents_based_on_a_common_value_in_an_array_in_MongoDB\" title=\"2. Can I update documents based on a common value in an array in MongoDB?\">2. Can I update documents based on a common value in an array in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#3_Is_it_possible_to_count_the_occurrences_of_a_specific_value_in_an_array_in_MongoDB\" title=\"3. Is it possible to count the occurrences of a specific value in an array in MongoDB?\">3. Is it possible to count the occurrences of a specific value in an array in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#4_How_can_I_find_the_second_most_common_value_in_an_array_in_MongoDB\" title=\"4. How can I find the second most common value in an array in MongoDB?\">4. How can I find the second most common value in an array in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#5_Is_it_efficient_to_find_common_values_in_arrays_using_MongoDB_aggregation\" title=\"5. Is it efficient to find common values in arrays using MongoDB aggregation?\">5. Is it efficient to find common values in arrays using MongoDB aggregation?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#6_Can_I_find_the_intersection_of_multiple_arrays_in_MongoDB\" title=\"6. Can I find the intersection of multiple arrays in MongoDB?\">6. Can I find the intersection of multiple arrays in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#7_How_can_I_find_the_union_of_multiple_arrays_in_MongoDB\" title=\"7. How can I find the union of multiple arrays in MongoDB?\">7. How can I find the union of multiple arrays in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#8_Is_there_a_way_to_find_documents_with_arrays_containing_all_of_the_specified_values_in_MongoDB\" title=\"8. Is there a way to find documents with arrays containing all of the specified values in MongoDB?\">8. Is there a way to find documents with arrays containing all of the specified values in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#9_How_can_I_find_the_average_length_of_arrays_in_MongoDB_documents\" title=\"9. How can I find the average length of arrays in MongoDB documents?\">9. How can I find the average length of arrays in MongoDB documents?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#10_Can_I_find_the_maximum_value_in_an_array_of_integers_in_MongoDB\" title=\"10. Can I find the maximum value in an array of integers in MongoDB?\">10. Can I find the maximum value in an array of integers in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#11_Is_it_possible_to_find_the_common_values_between_two_arrays_in_MongoDB\" title=\"11. Is it possible to find the common values between two arrays in MongoDB?\">11. Is it possible to find the common values between two arrays in MongoDB?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#12_How_can_I_find_documents_with_arrays_that_do_not_contain_a_specific_value_in_MongoDB\" title=\"12. How can I find documents with arrays that do not contain a specific value in MongoDB?\">12. How can I find documents with arrays that do not contain a specific value in MongoDB?<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"1_How_can_I_find_documents_containing_a_specific_value_in_an_array_in_MongoDB\"><\/span>1. How can I find documents containing a specific value in an array in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nTo find documents containing a specific value in an array in MongoDB, you can use the $elemMatch operator in a find query.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Can_I_update_documents_based_on_a_common_value_in_an_array_in_MongoDB\"><\/span>2. Can I update documents based on a common value in an array in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can update documents based on a common value in an array in MongoDB using the $set operator along with the $[] positional operator to update all elements matching the condition.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Is_it_possible_to_count_the_occurrences_of_a_specific_value_in_an_array_in_MongoDB\"><\/span>3. Is it possible to count the occurrences of a specific value in an array in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can count the occurrences of a specific value in an array in MongoDB using the $filter operator along with $size to get the count of filtered array elements.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_How_can_I_find_the_second_most_common_value_in_an_array_in_MongoDB\"><\/span>4. How can I find the second most common value in an array in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nTo find the second most common value in an array in MongoDB, you can use the $facet stage in aggregation to first group values and then sort them to get the second most common value.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"5_Is_it_efficient_to_find_common_values_in_arrays_using_MongoDB_aggregation\"><\/span>5. Is it efficient to find common values in arrays using MongoDB aggregation?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, using MongoDB aggregation to find common values in arrays is efficient as it allows you to manipulate and process data at the database level.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"6_Can_I_find_the_intersection_of_multiple_arrays_in_MongoDB\"><\/span>6. Can I find the intersection of multiple arrays in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can find the intersection of multiple arrays in MongoDB by using the $setIntersection operator in the aggregation framework.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"7_How_can_I_find_the_union_of_multiple_arrays_in_MongoDB\"><\/span>7. How can I find the union of multiple arrays in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nTo find the union of multiple arrays in MongoDB, you can use the $setUnion operator in the aggregation framework.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"8_Is_there_a_way_to_find_documents_with_arrays_containing_all_of_the_specified_values_in_MongoDB\"><\/span>8. Is there a way to find documents with arrays containing all of the specified values in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can find documents with arrays containing all of the specified values in MongoDB by using the $all operator in a find query.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"9_How_can_I_find_the_average_length_of_arrays_in_MongoDB_documents\"><\/span>9. How can I find the average length of arrays in MongoDB documents?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nTo find the average length of arrays in MongoDB documents, you can use the $map operator along with $avg in the aggregation pipeline.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"10_Can_I_find_the_maximum_value_in_an_array_of_integers_in_MongoDB\"><\/span>10. Can I find the maximum value in an array of integers in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can find the maximum value in an array of integers in MongoDB by using the $max operator in the aggregation framework.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"11_Is_it_possible_to_find_the_common_values_between_two_arrays_in_MongoDB\"><\/span>11. Is it possible to find the common values between two arrays in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can find the common values between two arrays in MongoDB by using the $setIntersection operator in the aggregation pipeline.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"12_How_can_I_find_documents_with_arrays_that_do_not_contain_a_specific_value_in_MongoDB\"><\/span>12. How can I find documents with arrays that do not contain a specific value in MongoDB?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nTo find documents with arrays that do not contain a specific value in MongoDB, you can use the $nin operator in a find query to exclude documents with the specified value.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a collection by a specified expression, and in this case, we can group by the array field and use the $push operator to create an array of all values. Once we &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to find a common value in an array in MongoDB?\" class=\"read-more button\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#more-169010\">Read more<span class=\"screen-reader-text\">How to find a common value in an array in MongoDB?<\/span><\/a><\/p>\n","protected":false},"author":41,"featured_media":107420,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86279],"tags":[],"class_list":["post-169010","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-learn","no-featured-image-padding"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to find a common value in an array in MongoDB?<\/title>\n<meta name=\"description\" content=\"In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to find a common value in an array in MongoDB?\" \/>\n<meta property=\"og:description\" content=\"In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/\" \/>\n<meta property=\"og:site_name\" content=\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/synchronyfinancial\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-05T09:23:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"500\" \/>\n\t<meta property=\"og:image:height\" content=\"164\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Alisha Bruce\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@synchrony\" \/>\n<meta name=\"twitter:site\" content=\"@synchrony\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alisha Bruce\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/\"},\"author\":{\"name\":\"Alisha Bruce\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/94ef8c983729b60de19bd9da87a2bdf0\"},\"headline\":\"How to find a common value in an array in MongoDB?\",\"datePublished\":\"2023-10-05T09:23:40+00:00\",\"dateModified\":\"2023-10-05T09:23:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/\"},\"wordCount\":605,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#organization\"},\"articleSection\":[\"Learn\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/\",\"url\":\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/\",\"name\":\"How to find a common value in an array in MongoDB?\",\"isPartOf\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#website\"},\"datePublished\":\"2023-10-05T09:23:40+00:00\",\"dateModified\":\"2023-10-05T09:23:40+00:00\",\"description\":\"In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a\",\"breadcrumb\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/namso-gen.co\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to find a common value in an array in MongoDB?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#website\",\"url\":\"https:\/\/namso-gen.co\/blog\/\",\"name\":\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\",\"description\":\"In Namso gen blog you can get many tips regarding to Credit cards, VCC, Credit card security etc. You can generate credit cards by using Namso-gen.co\",\"publisher\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/namso-gen.co\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#organization\",\"name\":\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\",\"url\":\"https:\/\/namso-gen.co\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png\",\"contentUrl\":\"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png\",\"width\":500,\"height\":164,\"caption\":\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\"},\"image\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/synchronyfinancial\",\"https:\/\/twitter.com\/synchrony\",\"https:\/\/www.youtube.com\/synchronyfinancial\",\"https:\/\/www.instagram.com\/synchrony\",\"https:\/\/www.linkedin.com\/company\/synchrony-financial\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/94ef8c983729b60de19bd9da87a2bdf0\",\"name\":\"Alisha Bruce\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"Alisha Bruce\"},\"description\":\"Guest author Alisha Bruce has meticulously crafted and revised this article to the best of their knowledge and understanding. Readers are strongly advised to exercise caution, verify information independently, and rely on their own judgment when considering the information provided. Read more articles on Namso Gen here.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to find a common value in an array in MongoDB?","description":"In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/","og_locale":"en_US","og_type":"article","og_title":"How to find a common value in an array in MongoDB?","og_description":"In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a","og_url":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/","og_site_name":"Namso Gen Blog - Free Credit Card Generator [100% Valid]","article_publisher":"https:\/\/www.facebook.com\/synchronyfinancial","article_published_time":"2023-10-05T09:23:40+00:00","og_image":[{"width":500,"height":164,"url":"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png","type":"image\/png"}],"author":"Alisha Bruce","twitter_card":"summary_large_image","twitter_creator":"@synchrony","twitter_site":"@synchrony","twitter_misc":{"Written by":"Alisha Bruce","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#article","isPartOf":{"@id":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/"},"author":{"name":"Alisha Bruce","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/94ef8c983729b60de19bd9da87a2bdf0"},"headline":"How to find a common value in an array in MongoDB?","datePublished":"2023-10-05T09:23:40+00:00","dateModified":"2023-10-05T09:23:40+00:00","mainEntityOfPage":{"@id":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/"},"wordCount":605,"commentCount":0,"publisher":{"@id":"https:\/\/namso-gen.co\/blog\/#organization"},"articleSection":["Learn"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/","url":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/","name":"How to find a common value in an array in MongoDB?","isPartOf":{"@id":"https:\/\/namso-gen.co\/blog\/#website"},"datePublished":"2023-10-05T09:23:40+00:00","dateModified":"2023-10-05T09:23:40+00:00","description":"In MongoDB, finding a common value in an array involves using the aggregation framework and the $group operator. The $group operator groups documents in a","breadcrumb":{"@id":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/namso-gen.co\/blog\/how-to-find-a-common-value-in-an-array-in-mongodb\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/namso-gen.co\/blog\/"},{"@type":"ListItem","position":2,"name":"How to find a common value in an array in MongoDB?"}]},{"@type":"WebSite","@id":"https:\/\/namso-gen.co\/blog\/#website","url":"https:\/\/namso-gen.co\/blog\/","name":"Namso Gen Blog - Free Credit Card Generator [100% Valid]","description":"In Namso gen blog you can get many tips regarding to Credit cards, VCC, Credit card security etc. You can generate credit cards by using Namso-gen.co","publisher":{"@id":"https:\/\/namso-gen.co\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/namso-gen.co\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/namso-gen.co\/blog\/#organization","name":"Namso Gen Blog - Free Credit Card Generator [100% Valid]","url":"https:\/\/namso-gen.co\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png","contentUrl":"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png","width":500,"height":164,"caption":"Namso Gen Blog - Free Credit Card Generator [100% Valid]"},"image":{"@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/synchronyfinancial","https:\/\/twitter.com\/synchrony","https:\/\/www.youtube.com\/synchronyfinancial","https:\/\/www.instagram.com\/synchrony","https:\/\/www.linkedin.com\/company\/synchrony-financial"]},{"@type":"Person","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/94ef8c983729b60de19bd9da87a2bdf0","name":"Alisha Bruce","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"Alisha Bruce"},"description":"Guest author Alisha Bruce has meticulously crafted and revised this article to the best of their knowledge and understanding. Readers are strongly advised to exercise caution, verify information independently, and rely on their own judgment when considering the information provided. Read more articles on Namso Gen here."}]}},"_links":{"self":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/posts\/169010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/comments?post=169010"}],"version-history":[{"count":0,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/posts\/169010\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/media\/107420"}],"wp:attachment":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/media?parent=169010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/categories?post=169010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/tags?post=169010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}