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

  • SEARCH
  • Home
  • 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 8485001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:31:29+00:00 2026-06-10T20:31:29+00:00

In a new version on MongoDB we can use an $elemMatch projection operator to

  • 0

In a new version on MongoDB we can use an $elemMatch projection operator to limit the response of a query to a single matching element of an array. http://docs.mongodb.org/manual/reference/projection/elemMatch/

But it seems doesn’t work yet in mongoose 3 here is the example:

{
 _id: ObjectId(5), 
 items: [1,2,3,45,4,67,9,4]
}

Folder.findOne({_id: Object(5)}, {$elemMatch: {$in: [1,67,9]}})
  .exec(function (err, doc) {

});

I’m expected to get the follows doc:

{
 _id: ObjectId(5), 
 items: [1,67,9]
}

But unfortunately what I’m getting is document with all items:

{
 _id: ObjectId(5), 
 items: [1,2,3,45,4,67,9,4]
}
  • 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-10T20:31:30+00:00Added an answer on June 10, 2026 at 8:31 pm

    The mongodb docs here are misleading, we’ll get them updated.

    What its saying is that you can now use $elemMatch in your projection, that is, your field selection:

    https://gist.github.com/3640687

    See also: https://github.com/learnboost/mongoose/issues/1085

    [Edit] pull request for docs sent: https://github.com/mongodb/docs/pull/185

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

Sidebar

Related Questions

I've installed a new version of Netbeans (6.8) and can't remember how to change
With the new version of CodeIgniter; you can only set rules in a static
A recent new jQuery version has been released, the jQuery v1.4. You can read
I am new to mongodb/mongomapper and can't find an answer to this. I have
I am waiting new aggregating framework of Mongodb. New aggregation framework query style documented
new Version of Firefox and IE8 seem to use one windows process. We have
I am following http://api.mongodb.org/scala/casbah/current/setting_up.html in order to use MongoDB with scala. I am new
The new version of SQLite has the ability to enforce Foreign Key constraints, but
I installed a new version of Apache server, I used options like --with-PACKAGE to
In the new version of Bouncy Castle library there are changes in PKCS10CertificationRequest .

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.