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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:18:03+00:00 2026-06-09T08:18:03+00:00

I have two collections in MongoDB Users (find()): { _id : ObjectId(5021314e372c50859ced7063), name :

  • 0

I have two collections in MongoDB

Users (find()):

{ "_id" : ObjectId("5021314e372c50859ced7063"), "name" : "Vinícius", "username" : "vinixhenri", "password" : "vinix123" }
{ "_id" : ObjectId("50213180372c50859ced7064"), "name" : "André", "username" : "andre", "password" : "andre123" }

and Projects (findOne()):

{
    "_id" : ObjectId("50215d09ddf7410905000000"),
    "name" : "Projeto X",
    "local" : "/home/server/compartilhamento/htdocs/project_x/",
    "permissions" : [
            {
                    "user" : "5021314e372c50859ced7063",
                    "alter" : true,
                    "view" : true,
                    "delete" : true,
                    "view_task" : true,
                    "insert_task" : true,
                    "alter_task" : true,
                    "delete_task" : true
            },
            {
                    "user" : "50213180372c50859ced7064",
                    "alter" : true,
                    "view" : true,
                    "delete" : false,
                    "view_task" : false,
                    "insert_task" : false,
                    "alter_task" : false,
                    "delete_task" : false
            }
    ],
    "tasks" : [
            {
                    "responsible" : "5021314e372c50859ced7063",
                    "description" : "Ajuste na barra lateral do site"
            },
            {
                    "responsible" : "5021314e372c50859ced7063",
                    "description" : "Ajuste no cabeçalho do site"
            },
            {
                    "responsible" : "50213180372c50859ced7064",
                    "description" : "Ajuste no rodapé do site"
            }
    ]

}

I showed up a findOne() collection of projects, but I wonder how it would be a find() also.

How would I do to get all the tasks where the charge has the username “vinixhenri”? The user identifier is tasks-> responsible.

I wonder also if I’m doing right in keeping the _id user? It is correct I have to consult the user information and then re-queries the database for project information? Or should I duplicate information about users’ tasks in the collection?

  • 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-09T08:18:06+00:00Added an answer on June 9, 2026 at 8:18 am

    The most appropiate way until 2.2 (where you would have: https://jira.mongodb.org/browse/SERVER-828 or even the aggregation framework) would be to either:

    • Return all Root documents with one or more tasks with the “charge” of the particular user filtering them out on client side to get only those tasks across those project associated with that user which could work really well.

    • Run an MR (not so recommended) which will, once every so oftern, reformat your documents to the perpestive you need.

    Note: The MR would not be realtime however you can make the client side filtering realtime as such I would personally choose to filter this out on client side.

    I wonder also if I’m doing right in keeping the _id user? It is
    correct I have to consult the user information and then re-queries the
    database for project information? Or should I duplicate information
    about users’ tasks in the collection?

    Yes this is fine and performant. For example say that the user changes their username you don’t want to go through all the project docs changing their username do you? Having to query for an external row retrieving all information updates comes with it’s expenses but also it benefits. In this case it would be bad to replicate the users data onto the project document.

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

Sidebar

Related Questions

Consider I have two collections in MongoDB. One for products with documents like: {'_id':
say i have two collections in mongodb,one for users which contains users basic info,and
I have two collections: Users Uploads Each upload has a User associated with it
Supposing I have two collections, posts and comments. post = { _id: 1, language:
I have a sorted (Mongodb) collection of objects: {_id: ObjectId(...), person: Homer, order: 1},
I have two collections as below which hold IDs for Students. The ids are
I have two generic collections in my code, EventableCollection and EventableSortedList - which are
I have a class which has two HashSet<String> collections as private members. Other classes
I have two collections of my own reference-type objects that I wrote my own
If I have two collections of files: A and B (say, two collections of

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.