If the document has been stored, and now you want to add a description attribute to the document, you can update it like this:
Mongo mongo =
“bh_code_a_Java_keywords”>new Mongo(
“bh_code_a_Java_keywords”>this.host,
“bh_code_a_Java_keywords”>this.port);
GridFS fs =
“bh_code_a_Java_keywords”>new GridFS(mongo.getDB(“database”));
GridFSDBFile file = fs.find(
“bh_code_a_Java_keywords”>new ObjectId(document.getId()));
file.put(
“bh_code_a_Java_string”>”description”, document.getDescription());
file. save();
You can also use the update method of DBCollection to update,
DBObject queryCOndition=
“bh_code_a_Java_keywords”>new BasicDBObject();
queryCondition. put(
“bh_code_a_Java_string”>”_id”, document.getId());
Mongo mongo =
“bh_code_a_Java_keywords”>new Mongo(
“bh_code_a_Java_keywords”>this.host,
“bh_code_a_Java_keywords”>this.port);
DB db = mongo.getDB(
“bh_code_a_Java_string”>”database”)
DBCollection c = db.getCollection(
“bh_code_a_Java_string”>”fs.files”);
DBObject updatedValue=
“bh_code_a_Java_keywords”>new BasicDBObject();
updatedValue. put(
“bh_code_a_Java_string”>”description”, document.getDescription());
DBObject updateSetValue=
“bh_code_a_Java_keywords”>new BasicDBObject(
“bh_code_a_Java_string”>”$set”,updatedValue);
c.update(updateSetValue, updateSetValue);