Examples of formatObject()


Examples of org.nutz.mongo.entity.MongoEntity.formatObject()

    // 获得集合
    String collName = moe.getCollectionName(q);
    if (db.collectionExists(collName)) {
      DBCollection coll = db.getCollection(collName);
      // 将 ref 对象转换成 DBObject
      DBObject dbRef = moe.formatObject(q);
      DBObject dbo = null == dbRef ? coll.findOne() : coll.findOne(dbRef);
      // 执行转换
      return (T) moe.toObject(dbo);
    }
    return null;
View Full Code Here

Examples of org.nutz.mongo.entity.MongoEntity.formatObject()

  public long count(Object enref, Object q) {
    MongoEntity moe = Mongos.entity(enref);
    String collName = moe.getCollectionName(q);
    if (db.collectionExists(collName)) {
      DBCollection coll = db.getCollection(collName);
      DBObject dbq = moe.formatObject(q);
      return null == q ? coll.count() : coll.count(dbq);
    }
    return -1;
  }
View Full Code Here

Examples of org.nutz.mongo.entity.MongoEntity.formatObject()

    MongoEntity moe = Mongos.entity(enref);
    String fieldName = moe.getFieldDbName(field);
    String collName = moe.getCollectionName(q);
    if (db.collectionExists(collName)) {
      DBCollection coll = db.getCollection(collName);
      DBObject dbq = moe.formatObject(q);

      String reduce = "function(obj,prev){prev.csum+=obj." + fieldName + ";}";

      GroupCommand gcmd = new GroupCommandcoll,
                          Mongos.dbo(),
View Full Code Here

Examples of org.nutz.mongo.entity.MongoEntity.formatObject()

    // 创建索引
    if (moe.hasIndexes()) {
      for (MongoEntityIndex mei : moe.getIndexes()) {
        DBCollection coll = db.getCollection(collName);
        DBObject keys = moe.formatObject(mei.getFields());
        // 采用默认的名称
        if (Strings.isBlank(mei.getName())) {
          coll.ensureIndex(keys, Mongos.dbo("unique", mei.isUnique()));
        }
        // 采用自定义名称
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.