I have two collection:
data class Product(
@Contextual
@SerialName("_id") val _id: Id<Product> = newId(),
val name: String,
val description: String,
val price: Double,
val deliveryPrice: Double
)
and
data class ProductOption(
@Contextual
@SerialName("_id") val _id: Id<ProductOption>? = newId(),
val name: String,
val description: String,
val productId: Id<Product>
)
There is 1: M relationship between the two collection as shown in the data class. And want to delete given ProductOption for a specific product.
val deletedResult =
runBlocking {
prodCol.findOneById(ObjectId("5fc2e2a041aab268eead535e"))?.
also {
prodOptionCol.deleteOne(
and (ProductOption::_id eq ObjectId("5fc2e89c2f48cb220c7f9da2"), ProductOption::productId
eq it._id ))
}
}
"eq" operator does not work when comparing the _id for the production option. Could not find an example where we can compare the org.bson.types.ObjectId.
Is there a better way to do it.
Any help will be appreciated .
Kind Regards,
Saurav Jha