真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

mongoDB中distinct的使用

需求:在MongoDB中查詢一個類型(數(shù)據(jù)庫中可能百萬條數(shù)據(jù))用作下拉列表查詢。
在工具中用 db.getCollection('order').distinct("typeName") 即可實現(xiàn)。
java 代碼:
MongoCollection coll = this.client.getDatabase(this.databaseName).getCollection('order');
//獲得mongodb數(shù)據(jù)庫連接 getCollection表名
//this.databaseName 來自配置文件直接讀取動態(tài)配置,即數(shù)據(jù)庫名稱
Iterable iterable = coll.distinct('typeName',String);
// String 查詢的值 是什么類型,由于本次查詢的為漢字,所以是String
MongoCursor it = iterable.iterator();
while(it.hasNext()) {
String typeName = it.next().toString()
System.out.pringln(typeName)
}

創(chuàng)新互聯(lián)是一家專注于網(wǎng)站建設(shè)、成都做網(wǎng)站與策劃設(shè)計,牡丹江網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:牡丹江等地區(qū)。牡丹江做網(wǎng)站價格咨詢:028-86922220

            /*****
            MongoCollection : com.mongodb.client.MongoCollection
            Document:org.bson.Document 
            implements Map, Serializable, Bson
            **/

當前題目:mongoDB中distinct的使用
網(wǎng)站URL:http://weahome.cn/article/ihhieg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部