org.mongodb.morphia.Datastore.getCollection()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.mongodb.morphia.Datastore.getCollection()方法的一些代码示例,展示了Datastore.getCollection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datastore.getCollection()方法的具体详情如下:
包路径:org.mongodb.morphia.Datastore
类名称:Datastore
方法名:getCollection

Datastore.getCollection介绍

暂无

代码示例

代码示例来源:origin: querydsl/querydsl

@Override
protected DBCollection getCollection(Class<?> type) {
  return datastore.getCollection(type);
}

代码示例来源:origin: querydsl/querydsl

public MorphiaQuery(final Morphia morphia, final Datastore datastore,
          final EntityCache cache, final Class<? extends K> entityType) {
  super(datastore.getCollection(entityType), new Function<DBObject, K>() {
    @Override
    public K apply(DBObject dbObject) {
      return morphia.fromDBObject(datastore, entityType, dbObject, cache);
    }
  }, new MorphiaSerializer(morphia));
  this.datastore = datastore;
  this.cache = cache;
}

代码示例来源:origin: com.mysema.querydsl/querydsl-mongodb

@Override
protected DBCollection getCollection(Class<?> type) {
  return datastore.getCollection(type);
}

代码示例来源:origin: com.mysema.querydsl/querydsl-mongodb

public MorphiaQuery(final Morphia morphia, final Datastore datastore,
    final EntityCache cache, final Class<? extends K> entityType) {
  super(datastore.getCollection(entityType), new Function<DBObject, K>() {
    @Override
    public K apply(DBObject dbObject) {
      return morphia.fromDBObject(entityType, dbObject, cache);
    }
  }, new MorphiaSerializer(morphia));
  this.datastore = datastore;
  this.cache = cache;
}

代码示例来源:origin: BlackLabs/play-morphia

public DBCollection col() {
  return ds().getCollection(c_);
}

代码示例来源:origin: BlackLabs/play-morphia

public DBCollection col() {
  return ds().getCollection(c_);
}

代码示例来源:origin: BlackLabs/play-morphia

public static void delete(Class ... types) {
  idCache.clear();
  for (Class<? extends Model> type: types) {
    ds().getCollection(type).drop();
  }
}

代码示例来源:origin: BlackLabs/play-morphia

public static void delete(List<Class<? extends play.db.Model>> classes) {
  idCache.clear();
  for (Class<? extends play.db.Model> type: classes) {
    ds().getCollection(type).drop();
  }
}

代码示例来源:origin: protegeproject/webprotege

@Nonnull
  @Override
  public Optional<UserId> getUserIdForApiKey(@Nonnull HashedApiKey apiKey) {
    DBCollection collection = datastore.getCollection(UserApiKeys.class);
    DBObject query = object(API_KEYS__API_KEY, apiKey.get());
    DBObject projection = object(USER_ID, INCLUDE);
    DBObject found = collection.findOne(query, projection);
    return Optional.ofNullable(found)
            .map(object -> object.get(USER_ID).toString())
            .map(UserId::getUserId);
  }
}

代码示例来源:origin: BlackLabs/play-morphia

public static void deleteDatabase() {
  idCache.clear();
  Datastore ds = ds();
  for (Class<Model> clz: Play.classloader.getAssignableClasses(Model.class)) {
    ds.getCollection(clz).drop();
  }
}

代码示例来源:origin: org.actframework/act-morphia

public DBCollection collection() {
  return ds().getCollection(modelType());
}

代码示例来源:origin: BlackLabs/play-morphia

public static <T extends Model> WriteResult insert(List<T> entities) {
  if (entities.isEmpty()) return null;
  T t = entities.get(0);
  List<DBObject> l = new ArrayList<DBObject>(entities.size());
  Morphia morphia = MorphiaPlugin.morphia();
  boolean populateId = !MorphiaPlugin.getIdType().isObjectId();
  for (T entity: entities) {
    if (populateId) entity.setId(IdGenerator.generateId(entity));
    l.add(morphia.toDBObject(entity));
  }
  return t.ds().getCollection(t.getClass()).insert(l);
}

代码示例来源:origin: BlackLabs/play-morphia

/**
 *
 * @param groupKeys
 *            could be either "f1Andf2.." or "f1 f2" or "f1,f2"
 * @return
 */
public List<BasicDBObject> group(String groupKeys, DBObject initial,
    String reduce, String finalize) {
  DBObject key = new BasicDBObject();
  if (!S.empty(groupKeys)) {
    if (groupKeys.startsWith("by"))
      groupKeys = groupKeys.substring(2);
    String[] sa = groupKeys.split("(And|[\\s,;]+)");
    for (String s : sa) {
      key.put(MorphiaPlugin.mongoColName(c_, s), true);
    }
  }
  return (List<BasicDBObject>) ds().getCollection(c_).group(key,
      q_.getQueryObject(), initial, reduce, finalize);
}

代码示例来源:origin: org.actframework/act-morphia

private List<BasicDBObject> group(String groupKeys, DBObject initial,
                 String reduce, String finalize) {
  DBObject key = new BasicDBObject();
  if (!S.empty(groupKeys)) {
    String[] sa = MorphiaService.splitGroupKeys(groupKeys);
    for (String s : sa) {
      key.put(s, true);
    }
  }
  return (List<BasicDBObject>) ds.getCollection(modelType).group(key, mq.getQueryObject(), initial, reduce, finalize);
}

代码示例来源:origin: protegeproject/webprotege

@Override
public void dropApiKey(@Nonnull UserId userId,
            @Nonnull ApiKeyId apiKeyId) {
  DBCollection collection = datastore.getCollection(UserApiKeys.class);
  DBObject ops = object("$pull",
             // From
             object(API_KEYS,
                 // where
                 object(API_KEY_ID, apiKeyId.getId())));
  // Match the UserId
  DBObject query = object(USER_ID, userId.getUserName());
  collection.update(query, ops);
}

代码示例来源:origin: org.mongodb.morphia/morphia

collection = datastore.getCollection(key.getType());
  id = ref;
} else {

相关文章