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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:29:54+00:00 2026-06-13T11:29:54+00:00

I have collections of users and posts. User looks like { _id : ObjectId(5089cc4c7b03b9902b000000),

  • 0

I have collections of users and posts.

User looks like

{ "_id" : ObjectId("5089cc4c7b03b9902b000000"), "facebook_id" : "522128874" }

Post looks like

{ "_id" : ObjectId("508aa21b7b03b9780800000f"), "facebook_id" : "10150709375878875", "user" : DBRef("User", ObjectId("5089cc4c7b03b9902b000000")), "message" : " Julia dream, dreamboat queen, queen of all my dreams", "updated_time" : 1333502938 }

I want to find all the posts of a specific user.

$user = $userRepo->findOneByFacebookId('522128874');
$posts = $postRepo->findOneByUser($user)

It doesn’t work. I’ve also tried

$posts = $postRepo->findOneBy(array('user' => $user))

and

$posts = $postRepo->findOneBy(array('user' => $user->getId()))
  • 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-13T11:29:55+00:00Added an answer on June 13, 2026 at 11:29 am

    If you mapped your document relationships correctly, all you would need to do is just

    $user = $userRepo->findOneByFacebookId($fbid);
    $posts = $user->getPosts();
    

    You might want to look at Bidirectional References Doctrine Documentation

    If you want to find the posts of the user manually (the more tedious way), you have to create the method called findOneByUser($user) inside your Post repository. Then you will have to convert user ID to to a MongoId then use querybuilder to match user.$id field to the MongoId which will return cursor(s).

    Remember, when you create a document (post in this case) that has reference to another document, it stores the reference via its MongoId, so you cannot simply just do findOneByUser($user) unless you have created this method yourself.

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

Sidebar

Related Questions

I have a collection of Posts and Users where users can upvote/downvote each post.
I have three models: class Book < ActiveRecord::Base has_many :collections has_many :users, :through =>
I have 2 collections, one of available features and one of user features. I
I have multiple Users, each with a collection of Tasks. public class User {
I have a collection of user models that starts with basic data: [ {'_id':
I have a collection of posts created by separate users in my database. Each
I have an app and I am able to post to a user's wall
Hi I have a posts model and a collections model, joined together by a
I have a list: Collection users which has around 100K+ records of users (all
I have a form where users can modify a collection of objects using a

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.