package hellomongo;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import javax.management.Query;
import java.util.List
import org.bson.types.ObjectId;
public class Update {
private final static String HOST = "localhost";
private final static int PORT = 27017;
public static void main(String args[]) {
MongoClient mongoClient = new MongoClient(HOST, PORT);
DB db = mongoClient.getDB("admin");
DBCollection coll = db.getCollection("command");
ArrayList<Document> docList = new ArrayList<Document>();
docList.add(new Document().append("d", 4));
Document push = new Document().append(
"$push", new Document().append("cmd",
new Document().append("$each", docList).append("$position", 3)));
coll.updateMany(new Document().append("_id","5b02a14804ed7d6c3ca1c262"), push);
}