當前位置: 首頁>>代碼示例>>Java>>正文


Java DBCollection.count方法代碼示例

本文整理匯總了Java中com.mongodb.DBCollection.count方法的典型用法代碼示例。如果您正苦於以下問題:Java DBCollection.count方法的具體用法?Java DBCollection.count怎麽用?Java DBCollection.count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.mongodb.DBCollection的用法示例。


在下文中一共展示了DBCollection.count方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: snapshotCount

import com.mongodb.DBCollection; //導入方法依賴的package包/類
@Override
public <T extends Model> Long snapshotCount(Class<T> modelClass, Map<String, Object> filter) {
    if (modelClass == null)
        throw new DaoException("Model class cannot be null");

    if (filter == null)
        filter = EMPTY_FILTER;

    DBObject dbObject = buildQueryFilter(modelClass, filter, null);

    DBCollection col = collection(modelClass, true);

    Long count = col.count(dbObject);

    if (count != null) {
        app.setQueryMetadata(QueryMetadata.builder().count(count).build());
    }

    return count;
}
 
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:21,代碼來源:AbstractMongoDao.java

示例2: count

import com.mongodb.DBCollection; //導入方法依賴的package包/類
/**
   * 分頁查詢,count
   * @param dbName
   * @param collName
   * @param query
   * @return
   */
  public static long count(String dbName, String collName, DBObject query) {
  	DBCollection collection = getCollection(dbName, collName);
  	if (collection != null) {
	return collection.count(query);
}
      return -1;
  }
 
開發者ID:xuxueli,項目名稱:xxl-incubator,代碼行數:15,代碼來源:MongoDBUtil.java

示例3: getQueryCount

import com.mongodb.DBCollection; //導入方法依賴的package包/類
private long getQueryCount(DBCollection collection) {
	DBObject query = getQuery();
	if (null == query) {
		return collection.count();
	} else {
		return collection.count(query);
	}
}
 
開發者ID:xsonorg,項目名稱:tangyuan2,代碼行數:9,代碼來源:SelectVo.java

示例4: readPatternsFromMongo

import com.mongodb.DBCollection; //導入方法依賴的package包/類
private List<PatternReference> readPatternsFromMongo() {
	// TODO: Ideally this would do something in a more streaming manner, as there are likely to
	// be lots of examples

	DBCollection collection = mongo.getDB().getCollection(patternCollection);

	List<PatternReference> patterns = new ArrayList<>((int) collection.count());

	DBCursor cursor = collection.find();
	while (cursor.hasNext()) {
		DBObject o = cursor.next();
		// TODO: We don't currently use types (entity source target) but we could do
		// at least to output something to the relationship type filter

		BasicDBList list = (BasicDBList) o.get("words");
		List<Word> tokens = list.stream().map(l -> {
			BasicDBObject dbo = (BasicDBObject) l;
			String pos = dbo.getString("pos");
			String lemma = dbo.getString("lemma");

			// Fall back to actual text if no lemma
			if (lemma == null) {
				lemma = dbo.getString("text");
			}

			return new Word(lemma.trim().toLowerCase(), WordNetUtils.toPos(pos));
		}).filter(w -> w.getPos() != null)
				.collect(Collectors.toList());

		patterns.add(new PatternReference(o.get("_id").toString(), tokens));
	}

	return patterns;

}
 
開發者ID:tenode,項目名稱:baleen-extras,代碼行數:36,代碼來源:IdentifyInteractions.java

示例5: onRootAccess

import com.mongodb.DBCollection; //導入方法依賴的package包/類
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody Result onRootAccess() {

    DBCollection collection = mongoTemplate.getCollection("test");
    long count = collection.getCount();
    log.info("Object count in 'test' collection before insert: " + count + "<br/> Inserting one object.<br/>");

    BasicDBObject dBObject = new BasicDBObject();
    dBObject.put("hello", "world");
    collection.insert(dBObject);
    count = collection.count();
    log.info("Object count in test collection after insert:" + count);

    Result result = new Result();
    List<DBObject> dbObjects = new ArrayList<DBObject>();
    DBCursor cursor = collection.find();
    while (cursor.hasNext()) {
        com.mongodb.DBObject obj = cursor.next();
        final String value = (String) obj.get("hello");
        DBObject object = new DBObject();
        object.setKey("hello");
        object.setValue(value);
        dbObjects.add(object);
    }
    result.setDbObjects(dbObjects);
    result.setStatus(
            "Successfully accessed Mongodb service. Retrieving the data object inserted in test collection.");
    collection.drop();
    return result;
}
 
開發者ID:SAP,項目名稱:hcp-cloud-foundry-tutorials,代碼行數:31,代碼來源:RootController.java

示例6: get

import com.mongodb.DBCollection; //導入方法依賴的package包/類
@Override
public Object get(String key) throws PageException {
	DBCollection coll = db.getCollection(key);
	if(coll.count()!=0 || containsKey(key)) return toCFML(coll);
	throw exp.createExpressionException("key ["+key+"] doesn't exist ");
}
 
開發者ID:lucee,項目名稱:extension-mongodb,代碼行數:7,代碼來源:DBImpl.java

示例7: count

import com.mongodb.DBCollection; //導入方法依賴的package包/類
private static long count(DBObject query) {
  DBCollection collection = MongoFactory.getDB().getCollection(collectionName);
  return collection.count(query);
}
 
開發者ID:telefonicaid,項目名稱:fiware-sinfonier,代碼行數:5,代碼來源:Module.java

示例8: count

import com.mongodb.DBCollection; //導入方法依賴的package包/類
private static long count(DBObject query) {
  DBCollection collection = MongoFactory.getDB().getCollection(getCollectionName());
  return collection.count(query);
}
 
開發者ID:telefonicaid,項目名稱:fiware-sinfonier,代碼行數:5,代碼來源:Topology.java


注:本文中的com.mongodb.DBCollection.count方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。