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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:50:34+00:00 2026-05-26T14:50:34+00:00

I have a large collection of 300 question objects in a database test .

  • 0

I have a large collection of 300 question objects in a database test. I can interact with this collection easily through MongoDB’s interactive shell; however, when I try to get the collection through Mongoose in an express.js application I get an empty array.

My question is, how can I access this already existing dataset instead of recreating it in express? Here’s some code:

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

mongoose.connect('mongodb://localhost/test');
mongoose.model('question', new Schema({ url: String, text: String, id: Number }));

var questions = mongoose.model('question');
questions.find({}, function(err, data) { console.log(err, data, data.length); });

This outputs:

null [] 0
  • 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-05-26T14:50:34+00:00Added an answer on May 26, 2026 at 2:50 pm

    Mongoose added the ability to specify the collection name under the schema, or as the third argument when declaring the model. Otherwise it will use the pluralized version given by the name you map to the model.

    Try something like the following, either schema-mapped:

    new Schema({ url: String, text: String, id: Number}, 
               { collection : 'question' });   // collection name
    

    or model mapped:

    mongoose.model('Question', 
                   new Schema({ url: String, text: String, id: Number}), 
                   'question');     // collection name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large (more than 100K objects) collection of Java objects like below.
I have a large collection of objects and I need to figure out the
I have a large collection of CoreData objects which represent files. Periodically, I need
I have a large collection of small objects, each has a unique string ident.
I have a large collection of custom objects that I have retrieved from a
I have a MYSQL database containing the names of a large collection of people.
If I have a large collection (40m+ objects) and I'm looking to find: (a
I have a large collection (~2.7 million documents) in mongodb, and there are a
I have a large collection of retro games consoles and computers, I want to
I have a large collection of data in an excel file (and csv files).

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.