我试图批量插入 100 个文档对象。我是否错误地使用了插入语句?
Mongo mongoClient = new Mongo( "localhost" , 27017 );
DB db = mongoClient.getDB( "user" );
DBCollection coll = db.getCollection("test");
BasicDBObject doc = new BasicDBObject("userName","James").append("random1", "feeof").append("random2", "ofeijfefe");
List<DBObject> postsList = new ArrayList<DBObject>();
for ( int i = 0; i != 100; i++)
{
postsList.add(doc);
}
coll.insert(postsList);
它没有插入任何东西,当我检查最后一行时,它显示的值为N/A。