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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:52:48+00:00 2026-06-08T21:52:48+00:00

I really really need help in this. I am using node.js with mongodb and

  • 0

I really really need help in this. I am using node.js with mongodb and mongoose. So far I’ve managed to create a schema and save those into my database.

var Bericht = new Schema({
    name     : String
  , mail     : String
  , betreff  : String
  , inhalt   : String
  , datum    : Date
});
var Bericht = mongoose.model('Bericht', Bericht);

I habe a html formular where I can transmit with misc. fields data, by querystring I converting those into readable strings

var bericht_data = { 
name: tempo.Name
, mail: tempo.Mail
, betreff: tempo.Betreff
, inhalt: tempo.Inhalt
};
var testoro = new Bericht(bericht_data);
testoro.save(function (err) {
  if (!err) console.log('Success!');
}); 

so tempo.Name for example is a string and it also successful in saving it.
So far I can save all data from this formular into my mongodb.

Now the very problem: I want the data back as string to handle for dynamic html.
To get the info into my console, I use

Bericht.find(
{},
{ '_id': 0},
        function(err, docs) {
        if (!err){ 
               console.log(docs);
          // process.exit();
                  }
        else { throw err;}
        }
);

The console gives me all data which was ever saved in my schema Bericht excluding the long _id stuff. Sample output:
[ { name: ‘Hans’, mail: ‘hans@wurst.de’, betreff: ‘I lost my wurst’, inhalt: ‘look at me, I am amazing’ } ]
That’s just one, normally there would be a huge amount of data.
The idea is right now to extract only the name into a string like “Hans”. I want to get this name into a var, but hell it seems impossible!
I’ve tried

Bericht.find(
{},
{ '_id': 0},
        function(err, docs) {
        if (!err){ 
               console.log(docs.name);
          // process.exit();
                  }
        else { throw err;}
        }
);

But the I get only “undefined” delivered. I appreciate your help!

  • 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-08T21:52:49+00:00Added an answer on June 8, 2026 at 9:52 pm

    Take a look at Mongoose QueryStreams. I haven’t used it myself, but I’ve modified their example code to fit your Model, to give you an idea of how it might work in practice:

    var stream = Bericht.find().stream()
      , names = []
      , i;
    
    function closeHandler() {
      console.log(JSON.stringify(names));
    };
    
    stream.on('data', function (doc) {
      if (doc.name) {
        names.push(doc.name);
      }
    })
    
    stream.on('error', function (err) {
      // handle err
    })
    
    stream.on('close', closeHandler)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really need help this time - Joomla 2.5 and latest K2. I'm using
Sorry to bother again, but I really need help transforming this Python2 code into
I really need help with this last part of my program. I need to
I Really need help in this ... I'm building an application where I need
I really need help on this one. I am having a simple login form
I really need your help for this. I am relatively new to programming and
I really need some help with this as I have been trying to fix
We Really need some help on this one: We've Struggled with all the Apple
Okay, I really need some help with this. I'm new with designing and stuff,
I really need help here. I'm desperate at this point. I have NSOperation that

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.