Created
June 1, 2021 21:59
-
-
Save hi-manshu/06ba061d93c668c7b8b85684dc6ac317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postCollection.aggregate<Post>( | |
lookup( | |
"user", | |
listOf(Post::likes.variableDefinition()), | |
User::userId | |
), | |
match( | |
expr( | |
MongoOperator.and from listOf( | |
MongoOperator.`in` from listOf(User::userId, Post::likes), | |
MongoOperator.eq from listOf( | |
User::userId, "_id" | |
) | |
) | |
) | |
), | |
Post::likes.unwind(), | |
group( | |
fields( | |
User::userId from Post::likes | |
) | |
), | |
replaceRoot("_id".projection) | |
).toList() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment