Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Relationships and mongodb array in Laravel #2633

Unanswered
makssein asked this question in Q&A
Discussion options

I have a collection:

{
 ...
 users: ["..some objectID", "another objectID"]
 ...
}

Can I use relationships to get information about these users from the User model or do I need to make a separate query?

I understand that I can extract the ID and make a separate query using whereIn, but this will be very inefficient especially with pagination when a large amount of data is retrieved

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

This is how relationships are implemented. The string representation of ObjectId is used for compatibility with Eloquent. You should look at Relationships.

You must be logged in to vote
1 reply
Comment options

In my question I wrote that I want to use relationships, but I don’t know what kind and how

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /