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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:25:50+00:00 2026-06-18T01:25:50+00:00

This is the code: usermodel.findOne({ user: req.session.user }, function (err, user){ usermodel.find({ _id: {$in:

  • 0

This is the code:

usermodel.findOne({ user: req.session.user }, function (err, user){

   usermodel.find({ _id: {$in: user.follow } }, { user: true }, function (err, users){

         usermodel.find({ author: { $in: users.user }}, function (err, images){

          console.log(users);
          console.log(images);


        });
     });

And this is the Schema:

var userschema = new mongoose.Schema({

  user: String,
  follow: [String],
  message: [{ 

              title: String,
              author: String,
              message: String

           }],

});

The followarray contains the _ids of the users that the actual user is following. With the first usermodel.find y get the follow array. With the second usermodel.find, I get the users names:

[ { _id: 50fd9c7b8e6a9d087d000006, user: 'Mrmangado' },
  { _id: 50fd9d3ce20da1dd7d000006, user: 'kirbo' } ]

And, with the third and last usermodel.find, I’m trying to get the message of the users. I get the users’ names in the previous usermodel.find, and the author of the message has the same value of the user that has created it. The problem is the way I get the users’ names, I think I have to have the users’ names like this way:

[{ user: 'Mrmangado' },
 { user: 'kirbo' }]

If I receive an array like this, the $in statement will work perfectly. Is there any way to get an output like this…?

Thank’s advance!

  • 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-18T01:25:52+00:00Added an answer on June 18, 2026 at 1:25 am

    Are you sure that’s what you want? The author field is a user’s name, not its _id? If so, you could just map the resulting object to get the name.

    var usernames = users.map(function(u) { return u.user; });
    //= ["Mrmangado", "kirbo"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

main.js var http = require('http'); var UserModel = require('./models/user.js'); var server = http.createServer(function(req, res){
I have some code like this: var User = function () { _.bindAll(this) this.UserList
This code below allows me to find the word error in all my files
This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
I have this code in my user model: class User < ActiveRecord::Base attr_accessible :email,
Here is my edmx diagram. I am trying to use UserEntity.users.ToList<user>(); This provides me
This is my Schema: var userschema = new mongoose.Schema({ user: String, follow: [String], imagen:
This is my (simplified) code: Controller var userQuery = from u in _db.Users where
This code is the core of a much larger script that works great in
This code only renders a dodecahedron and completely ignores the glBegin(GL_TRIANGLES) block: glutSolidDodecahedron(); glBegin(GL_TRIANGLES);

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.