Populate Query based on List of Ids

52 views
Skip to first unread message

Himanshu Singh

unread,
Jun 1, 2021, 3:43:51 PM6/1/21
to kmongo
Hey I am having an issue here @zigzago

I have two collections.

One is Post which looks like this
data class Post(
@BsonId
val postId: String = ObjectId().toString(),
val title: String,
val post: String,
val likes: List<String> = emptyList(),
val createdAt: String? = null,
val createdBy: String? = null,
val updatedAt: String? = null,
val shortUrl: String? = null,
val isDeleted: Boolean? = false,
val comments: List<String> = emptyList()

and other is User which has userId and name.



My use case is in the post.likes which is a list of string of userIds. I want to do a call where I can populate the likes as literally user objects how we do in Mongoose. Lookup query is not working here.


Can you please help...Its a bit urgent

zigzago

unread,
Jun 6, 2021, 3:22:08 AM6/6/21
to kmongo
Hello,

Sorry, I don't understand the case. Why not populate the likes collection with user ids in kotlin  before saving or updating the Post ?

Regards
Reply all
Reply to author
Forward
0 new messages