This exception:
Exception in thread \"Thread-1\" java.lang.IllegalArgumentException: Invalid BSON field name id
at org.bson.AbstractBsonWriter.writeName(
updateOne
for updating document fields using update operators. You need replaceOne
which takes the replacement document.
_collection.replaceOne(
trackID,
track,
new UpdateOptions().upsert( true ));
More here
Update Operators: https://docs.mongodb.com/manual/reference/operator/update-field/
Update One:https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/
Replace One: https://docs.mongodb.com/manual/reference/method/db.collection.replaceOne/