@Serializable data class User( @Contextual @SerialName("_id") @JsonProperty("_id") val id: Id<User> = newId(), val nickName: String, val createdAt: Instant = System.now(), val updatedAt: Instant = createdAt, )
print user object:
User(id=6773740aed6dbd47aeb9718a, nickName=testBulkWrite, createdAt=2024-12-31T04:33:14.224893Z, updatedAt=2024-12-31T04:33:14.224893Z)
print user json string:
{"_id":"6773740aed6dbd47aeb9718a","nickName":"testBulkWrite","createdAt":"2024-12-31T04:33:14.224893Z","updatedAt":"2024-12-31T04:33:14.224893Z"}
When using the bulkWrite<User>("""[{ insertOne : { "document" : $userJson } }]""") method, the program executes to line 147 of "KMongoUtil.kt" where the value of if (!document.containsKey("_id")) is false. Should it be using document.getDocument("document").containsKey("_id") instead?
After testing, it should use """[{ insertOne : $userJson }]""".
|
if (!document.containsKey("_id")) { |

@Serializable data class User( @Contextual @SerialName("_id") @JsonProperty("_id") val id: Id<User> = newId(), val nickName: String, val createdAt: Instant = System.now(), val updatedAt: Instant = createdAt, )print user object:
User(id=6773740aed6dbd47aeb9718a, nickName=testBulkWrite, createdAt=2024-12-31T04:33:14.224893Z, updatedAt=2024-12-31T04:33:14.224893Z)print user json string:
{"_id":"6773740aed6dbd47aeb9718a","nickName":"testBulkWrite","createdAt":"2024-12-31T04:33:14.224893Z","updatedAt":"2024-12-31T04:33:14.224893Z"}When using thebulkWrite<User>("""[{ insertOne : { "document" : $userJson } }]""")method, the program executes to line 147 of "KMongoUtil.kt" where the value ofif (!document.containsKey("_id"))is false. Should it be usingdocument.getDocument("document").containsKey("_id")instead?After testing, it should use
"""[{ insertOne : $userJson }]""".kmongo/kmongo-shared/src/main/kotlin/org/litote/kmongo/util/KMongoUtil.kt
Line 147 in 0aecb9d