Adding values to an Array in MongoDB with Java
问题 I have a document stored in a collection in a mongo database. I want to be able to add to two arrays that are already in the document. Method for creating the document and arrays: public void addNewListName(String listName) { MongoCollection<Document> collection = database.getCollection("lists"); ArrayList< DBObject > array = new ArrayList< DBObject >(); Document list = new Document ("name", listName) .append("terms", array) .append("definitions", array); collection.insertOne(list); } Method