org.springframework.data.mongodb.core.MongoTemplate.getCollection()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(170)

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

MongoTemplate.getCollection介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-mongodb

@Override
public MongoCollection<Document> getCollection(String collectionName) {
  // native MongoDB objects that offer methods with ClientSession must not be proxied.
  return delegate.getCollection(collectionName);
}

代码示例来源:origin: kaaproject/kaa

protected DBCollection getPrimaryCollection() {
 return mongoTemplate.getCollection(getCollectionName());
}

代码示例来源:origin: spring-projects/spring-data-mongodb

if (mongoTemplate.getCollection(collName) == null) {
  mongoTemplate.createCollection(collName);

代码示例来源:origin: spring-projects/spring-data-mongodb

FindIterable<Document> iterable = template.getCollection(options.getCollectionName()).find(filter)
    .cursorType(CursorType.TailableAwait).noCursorTimeout(true);

代码示例来源:origin: org.springframework.data/spring-data-mongodb

@Override
public MongoCollection<Document> getCollection(String collectionName) {
  // native MongoDB objects that offer methods with ClientSession must not be proxied.
  return delegate.getCollection(collectionName);
}

代码示例来源:origin: spring-projects/spring-integration

@Override
@ManagedAttribute
public long getMessageCount() {
  return this.template.getCollection(this.collectionName).countDocuments();
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public Iterator<MessageGroup> iterator() {
  Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
  Iterable<String> groupIds = mongoTemplate.getCollection(collectionName)
      .distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), String.class);
  return StreamSupport.stream(groupIds.spliterator(), false)
      .map(this::getMessageGroup)
      .iterator();
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public Iterator<MessageGroup> iterator() {
  List<MessageGroup> messageGroups = new ArrayList<>();
  Query query = Query.query(Criteria.where(GROUP_ID_KEY).exists(true));
  @SuppressWarnings("rawtypes")
  Iterable<String> groupIds = this.template.getCollection(this.collectionName)
      .distinct(GROUP_ID_KEY, query.getQueryObject(), String.class);
  for (Object groupId : groupIds) {
    messageGroups.add(getMessageGroup(groupId));
  }
  return messageGroups.iterator();
}

代码示例来源:origin: spring-projects/spring-integration

@Override
@ManagedAttribute
public int getMessageGroupCount() {
  Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
  return this.mongoTemplate.getCollection(this.collectionName)
      .distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), Object.class)
      .into(new ArrayList<>())
      .size();
}

代码示例来源:origin: spring-projects/spring-integration

@Override
@ManagedAttribute
public int getMessageGroupCount() {
  Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
  return this.template.getCollection(this.collectionName)
      .distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), Object.class)
      .into(new ArrayList<>())
      .size();
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

FindIterable<Document> iterable = template.getCollection(options.getCollectionName()).find(filter)
    .cursorType(CursorType.TailableAwait).noCursorTimeout(true);

代码示例来源:origin: spring-projects/spring-integration

@Override
public long getMessageCount() {
  Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
      .and(MessageDocumentFields.GROUP_ID).exists(false));
  return this.mongoTemplate.getCollection(this.collectionName).countDocuments(query.getQueryObject());
}

代码示例来源:origin: fi.vm.sade.haku/hakemus-api

@Autowired
public ApplicationOidDAOMongoImpl(final MongoTemplate mongoTemplate,
                 @Value("${application.oid.prefix}") final String oidPrefix) {
  this.oidPrefix = oidPrefix + ".";
  sequenceCollection = mongoTemplate.getCollection(SEQUENCE_NAME);
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) {
  if (properties.get("collection") != null) {
    this.mapName = (String) properties.get("collection");
  } else {
    this.mapName = mapName;
  }
  this.coll = mongoTemplate.getCollection(this.mapName);
  this.converter = new SpringMongoDBConverter(mongoTemplate);
}

代码示例来源:origin: pl.edu.icm.polindex/polindex-tools

@Override
public void drop() {
  mongoTemplate.getCollection(collectionName).drop();
  if (keepHistory) {
    mongoTemplate.getCollection(collectionNameHist).drop();
  }
  
  updateMongoSchema();
}

代码示例来源:origin: org.springframework.integration/spring-integration-mongodb

@Override
@ManagedAttribute
public long getMessageCount() {
  return this.template.getCollection(this.collectionName).countDocuments();
}

代码示例来源:origin: org.springframework.integration/spring-integration-mongodb

@Override
public Iterator<MessageGroup> iterator() {
  List<MessageGroup> messageGroups = new ArrayList<>();
  Query query = Query.query(Criteria.where(GROUP_ID_KEY).exists(true));
  @SuppressWarnings("rawtypes")
  Iterable<String> groupIds = this.template.getCollection(this.collectionName)
      .distinct(GROUP_ID_KEY, query.getQueryObject(), String.class);
  for (Object groupId : groupIds) {
    messageGroups.add(getMessageGroup(groupId));
  }
  return messageGroups.iterator();
}

代码示例来源:origin: org.springframework.integration/spring-integration-mongodb

@Override
@ManagedAttribute
public int getMessageGroupCount() {
  Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
  return this.mongoTemplate.getCollection(this.collectionName)
      .distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), Object.class)
      .into(new ArrayList<>())
      .size();
}

代码示例来源:origin: org.springframework.integration/spring-integration-mongodb

@Override
public long getMessageCount() {
  Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
      .and(MessageDocumentFields.GROUP_ID).exists(false));
  return this.mongoTemplate.getCollection(this.collectionName).countDocuments(query.getQueryObject());
}

代码示例来源:origin: com.epam.reportportal/commons-dao

@Override
public void onBeforeDelete(BeforeDeleteEvent<Project> event) {
  for (DBObject dbObject : mongoTemplate.getCollection(event.getCollectionName())
      .find(queryMapper.getMappedObject(event.getDBObject(), context.getPersistentEntity(Project.class)))) {
    final String id = dbObject.get("_id").toString();
    updateDefaultProject(id);
    removeProjectShareable(id);
    externalSystemRepository.deleteByProjectRef(id);
    activityRepository.deleteByProjectRef(id);
    launchRepository.deleteByProjectRef(id);
  }
}

相关文章