Hello guys,
Am using ktor and mongoDB as my backend for an android project. When inserting a document, the acknowledgement returns true, but when i get InsertedId, it returns null despite being inserted in the database
😶 4
🚔 1
r
Richard Gomez
06/17/2022, 3:03 PM
Have you tried looking at the bug tracker of your mongo database client to see if that's a known issue?
i
IsaacMart
06/17/2022, 3:13 PM
There seems to be a way with how one structures the id on the POJO. I havent found how when using ktor.
IsaacMart
06/17/2022, 3:14 PM
This is my data class
📃 1
📝 1
IsaacMart
06/19/2022, 7:45 PM
Finaly found a work around on the issue. Regarding retrieving the id from the inserted document after acknowledgement, you have to make an insertion then after the acknowledgement, retrieve the inserted id through another query using anotger unique field.
Normally the inserted document returns a Boolean of acknowledgement and the insertedId. But you will notice that the insertedId is null even when acknowledgement is true.