Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:09:19+00:00 2026-06-01T01:09:19+00:00

db.test.insert({_id:1,communications:[{type:’sms’}]}) db.test.find() { "_id" : 1, "communications" : [ { "type" : "sms" }

  • 0

db.test.insert({_id:1,communications:[{type:’sms’}]})

db.test.find()
{ "_id" : 1, "communications" : [ { "type" : "sms" } ] }

Ok, its inserted

db.test.find({‘communications’:{type:’sms’}})
{ "_id" : 1, "communications" : [ { "type" : "sms" } ] }

Ok, I can find it if its an exact match

db.test.update({_id:1}, {communications:[{type:’sms’,call_id:9878}]}

Now I updated it such that the hash nested in the array has two keys

.test.update({_id:1}, {communications:[{type:’sms’,call_id:9878}]})

But I can’t find it bc the hash is not the exact match! NOOOOO!

db.test.find({‘communications’:{type:’sms’}}).count()
=>0

So, how can I do a search like that where I want to match on one of the keys in a hash in an array?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:09:20+00:00Added an answer on June 1, 2026 at 1:09 am

    If I’ve understood correctly (no guarantees I have!), then I think what you are looking for is the dot notation.

    db.test.find({'communications.type':'sms'}).count()
    

    Here’s the reference on MongoDb.org with all the examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I insert time wait value in web test in Visual Studio 2008
I have the following table: CREATE TABLE TEST(ID TINYINT NULL, COL1 CHAR(1)) INSERT INTO
I have this select insert into test(t_name) (select users.first_name || '_' || users.last_name ||
I have function: char *zap(char *ar) { char pie[100] = INSERT INTO test (nazwa,
I have created a test table in MySQL and would like to insert 10
I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT
I am developing a test application that requires me to insert 1 million records
I have a test file that contains 1,2,3 2,3,4 5,6,7 I want to insert
i am trying to insert data as a test for this JQuery plugin Jquery-in-place-editor
create or replace trigger insert_test_id before insert on test where(test.name='Ash') begin insert into test(s_no)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.