Im trying to batch insert 100 of the doc Objects. Am I using the insert statement incorrectly?
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);
It doesn't insert anything ,when i inspect the last line it shows the value as N/A.
usedb userbefore looking at the count?use user.