MongoDB for Java Developers by 2015

MongoDB for Java Developers by 2015

Author:2015
Language: eng
Format: mobi, epub
Publisher: Packt Publishing
Published: 0101-01-01T00:00:00+00:00


MongoClient mongoClient = new MongoClient("localhost", 27017);

DB db = mongoClient.getDB("sampledb");

DBCollection coll = db.getCollection("textitems");

coll.insert(new BasicDBObject("_id", 1).append("text", "mytext"));

List<DBObject> list = coll.getIndexInfo();

for (DBObject obj:list)

System.out.println(obj);

}

The method getIndexInfo returns a list of the indexes for this collection as DBObject. This information is printed on the console, which in our case, outputs the following:

{ "v" : 1 , "key" : { "_id" : 1} , "name" : "_id_" , "ns" : "sampledb.textitems"}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.