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 8470563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:33:16+00:00 2026-06-10T16:33:16+00:00

I´ve defined the following schema with Mongoose: var mongoose = require(‘mongoose’); var Schema =

  • 0

I´ve defined the following schema with Mongoose:

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;

var New = new Schema({
    _id: ObjectId,
    lang: String,
    formatted: Boolean,
    downloaded: Date,
    content: {
        title: String,
        link: String,
        description: String,
        meta: String,
        author: String
    }
});

module.exports = New;

And I´m trying to execute the following query:

NewsModel.find({'lang':'en', 'content.link':'test'}).exec(callback);

The query doesn’ t respond and it never enters into the callback function. It’ s strange, because this type of query (search into two String fields) works good with another Schema that I’ ve defined, but no with this one. The other Schema is more is simpler, without any embedded document.

The strange thing is that the following works:

NewsModel.find({'lang':'en', 'formatted':true}).exec(callback);

Is there any Schema error? Any idea what I’ m doing wrong?

Thank you very much,

Luis Cappa.


[UPDATED]

I tried your suggestions, but no way. I think that there are only two options:

1. The Schema that I posted has something wrong.

2. Mongoose has problems querying to documents that embed complex parameters such as another document.

I’ve worked with MongoDB shell, MongoDB Java Driver and Spring MongoDB Data and that’ s the first time that I experience this strange behavior.

The queries that I’ ve tested are:

NewsModel.find({'lang':'en', 'content.link':'test'}).exec(callback);
NewsModel.find({'lang':'en'}).where('content.link').equals('test').exec(callback);
NewsModel.find({'content.link':'test'}).where('lang').equals('en').exec(callback);
NewsModel.find({'content.link':'test'}).exec(callback); //  That demonstrates that Mongoose has problems with subelements.
NewsModel.find().where('content.link').equals('test').exec(callback); // This one too.

And one example that works perfectly with MongoDB shell:

db.news.find({ 'content.link': /test/, lang: 'en' })

I’ m worried that Mongoose do not returns an empty response with zero results. Instead, it maintains the application in stand by waiting and waiting for a response and never enters at the callback function.

Any ideas? Did you experienced something similar?

Thanks a lot!

  • 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-10T16:33:17+00:00Added an answer on June 10, 2026 at 4:33 pm

    Resolved

    It was a query performance error with Mongoose. I´ve got a test collection with about 100K documents to which execute queries and I haven’ t defined a compound index with ‘lang’ and ‘content.link’. The queries delayed too much and Mongoose or MongoDB didn´t alert any timeout warning or error message. After defining a compound index the query worked O.K. However…

    1. The queries worked O.K executing them in MongoDB shell. I don’ t know why with Mongoose were so slow. Maybe serializing – deserializing – validating processes involved produced that delay.

    2. Even without any index defined I can’ t believe that that simple query has such poor performance with a simple test collection with only 100K documents. MongoDB itself consumes a lot of resources to handle queries and responses quickly. Honestly I expected more from MongoDB – Mongoose.

    My suggestions/advices:

    Take care about indexes configuration.

    If you want quick searchs take a look to any Node.js Apache Solr module.

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

Sidebar

Related Questions

I have the following generic schema to represent different types of information. var Record
If I have defined the following types: type category = Noun | Verb |
Does anyone know how to test Mongoose Validations? Example, I have the following Schema
I am relatively new to django. I have defined my db schema and validated
I have the following schema defined in the file 'doodil.install' as part of a
The example here http://mongoosejs.com/docs/populate.html Provides the following code var story1 = new Story({ title:
Suppose the following XAML defined window: <Window x:Class=LayoutTests.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:local=clr-namespace:LayoutTests Title=Window1> <Window.Resources> <XmlDataProvider
I've got the following selector defined in button_selector.xml <?xml version=1.0 encoding=utf-8?> <selector xmlns:android=http://schemas.android.com/apk/res/android> <item
I have defined following control template for my custom control. <ControlTemplate TargetType={x:Type local:CustomControl}> <Grid
I have defined following in a ResourceDictionary: <DockPanel x:Key=errorDisplay LastChildFill=False> <Border Background=Red DockPanel.Dock=Top> <TextBlock

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.