我正在尝试更新数据库以增加mongoDB内部版本号的更改。
{ "_id" : ObjectId("5afaa7fd3c670aa8c2bf9f08"),
"type" : "PP",
"revision" : {
"date" : "2018-05-23T10:50:20.798Z",
"version" : "1.4.23"
},
"location" : "https://www.tester.com/privacy-policy/"
}
我目前有这个,但它不起作用:
public void update_privacy()引发异常{
//Privacy ID
String privacy_id = "5afaa7fd3c670aa8c2bf9f08";
//Version ID
Double version = "version";
MongoClientURI connectionString = new MongoClientURI("mongodb://" + mongoConectionAddress + "/tester_platform?socketTimeoutMS=300000");
@SuppressWarnings("resource")
MongoClient mongoClient = new MongoClient(connectionString);
MongoDatabase database = mongoClient.getDatabase("tester");
MongoCollection<Document> collection = database.getCollection("document_revisions");
collection.find(eq("_id", new ObjectId(privacy_id))).first();
collection.find(eq("version", new ObjectId()));
collection.updateOne(version, version+1);
}