本文整理了Java中org.mongodb.morphia.Datastore.createQuery()
方法的一些代码示例,展示了Datastore.createQuery()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datastore.createQuery()
方法的具体详情如下:
包路径:org.mongodb.morphia.Datastore
类名称:Datastore
方法名:createQuery
[英]Returns a new query bound to the collection (a specific DBCollection)
[中]返回绑定到集合(特定DBCollection)的新查询
代码示例来源:origin: stackoverflow.com
MoDBIA_DAO dao = new MoDBIA_DAO(mongo, morphia, DB_Name);
Datastore dataStore = morphia.createDatastore(mongo, DB_Name);
Query<MoDBIAGlobals> query = dataStore.createQuery(MoDBIAGlobals.class).disableValidation();
query.field("data.FACEBOOK.channelId").equal("FB1234");
query.field("data.FACEBOOK.data.topic.NO_TOPIC").equal("NO_TOPIC");
QueryResults<MoDBIAGlobals> results = dao.find(query);
System.out.println("results: " + results);
System.out.println("results.count: " + results.countAll());
代码示例来源:origin: BlackLabs/play-morphia
public MorphiaQuery(Class<? extends Model> clazz) {
// super(clazz, ds().getCollection(clazz), ds());
q_ = (QueryImpl<? extends Model>) ds().createQuery(clazz);
c_ = clazz;
}
代码示例来源:origin: NationalSecurityAgency/lemongrenade
public List<LGJob> getAllByAge(int days) {
if (days <= 0) {
days = 1;
}
Calendar cdate = Calendar.getInstance();
days *= -1;
cdate.add(Calendar.DAY_OF_YEAR, days);
Query<LGJob> query = getDatastore().createQuery(LGJob.class).filter("createDate >=", cdate.getTime());
return query.asList();
}
代码示例来源:origin: NationalSecurityAgency/lemongrenade
/** */
public List<LGAdapterModel> getAll() {
return getDatastore().createQuery(LGAdapterModel.class).asList();
}
}
代码示例来源:origin: protegeproject/webprotege
private Query<CollectionItemData> createQuery(CollectionId collectionId) {
return datastore.createQuery(CollectionItemData.class)
.field(COLLECTION_ID).equal(collectionId);
}
}
代码示例来源:origin: protegeproject/webprotege
public Optional<EntityDiscussionThread> findThreadByCommentId(CommentId commentId) {
Query<EntityDiscussionThread> query = datastore.createQuery(EntityDiscussionThread.class)
.field(COMMENTS_ID).equal(commentId);
return Optional.ofNullable(query.get());
}
代码示例来源:origin: protegeproject/webprotege
@Override
public void setApiKeys(@Nonnull UserId userId, List<ApiKeyRecord> records) {
Set<ApiKeyId> ids = new HashSet<>();
List<ApiKeyRecord> nonDuplicates = records.stream()
.filter(r -> ids.add(r.getApiKeyId()))
.collect(Collectors.toList());
UpdateOperations<UserApiKeys> ops = datastore.createUpdateOperations(UserApiKeys.class)
.set(API_KEYS, nonDuplicates);
Query<UserApiKeys> query = datastore.createQuery(UserApiKeys.class)
.field(USER_ID).equal(userId);
datastore.update(query, ops, new UpdateOptions().upsert(true));
}
代码示例来源:origin: protegeproject/webprotege
public int getOpenCommentsCount(@Nonnull ProjectId projectId,
@Nonnull OWLEntity entity) {
return datastore.createQuery(EntityDiscussionThread.class)
.disableValidation()
.field(PROJECT_ID).equal(projectId)
.field(ENTITY).equal(entity)
.field(STATUS).equal(Status.OPEN)
.asList()
.stream().map(thread -> thread.getComments().size())
.reduce((left, right) -> left + right)
.orElse(0);
}
代码示例来源:origin: groupon/DotCi
public List<BuildInfo> getBuildHistory(final String nodeName) {
final List<DbBackedBuild> builds = getDatastore().createQuery(DbBackedBuild.class)
.field("builtOn").equal(nodeName)
.asList();
final List<BuildInfo> buildInfos = new ArrayList<>();
for (final DbBackedBuild build : builds) {
buildInfos.add(new BuildInfo(build));
}
return buildInfos;
}
代码示例来源:origin: protegeproject/webprotege
public List<EntityDiscussionThread> getThreadsInProject(ProjectId projectId) {
return datastore.createQuery(EntityDiscussionThread.class)
.field(PROJECT_ID).equal(projectId)
.asList();
}
}
代码示例来源:origin: NationalSecurityAgency/lemongrenade
public List<LGJob> getAllActive() {
Query<LGJob> q = getDatastore().createQuery(LGJob.class);
q.field("status").equal(LGJob.STATUS_PROCESSING);
List unfinished = q.asList();;
unfinished.addAll(getAllNew());
unfinished.addAll(getAllError());
return unfinished;
}
代码示例来源:origin: groupon/DotCi
public DynamicProject getProjectById(final ObjectId id) {
return getDatastore()
.createQuery(DynamicProject.class)
.field("id").equal(id)
.get();
}
代码示例来源:origin: NationalSecurityAgency/lemongrenade
public List<LGJob> getAllProcessing() {
Query<LGJob> q = getDatastore().createQuery(LGJob.class);
q.field("status").equal(LGJob.STATUS_PROCESSING);
return q.asList();
}
代码示例来源:origin: protegeproject/webprotege
public List<EntityDiscussionThread> findThreads(@Nonnull ProjectId projectId,
@Nonnull OWLEntity entity) {
datastore.createQuery(EntityDiscussionThread.class);
return datastore.find(EntityDiscussionThread.class)
.disableValidation()
.field(PROJECT_ID).equal(projectId)
.field(ENTITY).equal(entity)
.order("-comments.0.createdAt")
.asList();
}
代码示例来源:origin: groupon/DotCi
public Iterable<DynamicProject> getProjectsForOrg(final OrganizationContainer organizationContainer) {
return getDatastore().createQuery(DynamicProject.class).disableValidation()
.field("containerName").equal(organizationContainer.getName())
.asList();
}
代码示例来源:origin: groupon/DotCi
public int getNextBuildNumber(final DynamicProject project) {
final BuildNumberCounter seq = getDatastore().createQuery(BuildNumberCounter.class).field("key").equal(project.getFullName()).get();
if (seq == null) {
return 1;
}
return seq.getCounter() + 1;
}
代码示例来源:origin: groupon/DotCi
public DynamicProject getProjectForOrg(OrganizationContainer organizationContainer, String name) {
return getDatastore().createQuery(DynamicProject.class).disableValidation()
.field("containerName").equal(organizationContainer.getName())
.field("name").equal(name)
.get();
}
代码示例来源:origin: protegeproject/webprotege
public void store(ProjectId projectId, CollectionId collectionId, FormId formId, OWLEntity entity, FormData formData) {
Query<FormDataRecord> query = datastore.createQuery(FormDataRecord.class)
.field("projectId").equal(projectId)
.field("collectionId").equal(collectionId)
.field("formId").equal(formId)
.field("subjectId").equal(entity.toString());
UpdateOperations<FormDataRecord> update = datastore.createUpdateOperations(FormDataRecord.class);
update.set("data", formData);
datastore.update(query, update, new UpdateOptions().upsert(true));
}
代码示例来源:origin: groupon/DotCi
private Query<DynamicBuild> getDynamicBuildsForUser(final String user, final int numberOfBuilds) {
final Query<DynamicBuild> query = getDatastore().createQuery(DynamicBuild.class)
.limit(numberOfBuilds)
.disableValidation()
.order("-timestamp")
.field("className").equal("com.groupon.jenkins.dynamic.build.DynamicBuild");
query.or(
query.criteria("actions.causes.user").equal(user),
query.criteria("actions.causes.pusher").equal(user)
);
return query;
}
代码示例来源:origin: groupon/DotCi
public void delete(final DynamicProject project) {
// TODO do this in a query not iteratively in memory
for (final DynamicSubProject subProject : getChildren(project)) {
this.dynamicBuildRepository.delete(subProject);
getDatastore().delete(subProject);
}
this.dynamicBuildRepository.delete(project);
getDatastore().delete(project);
final BuildNumberCounter seq = getDatastore().createQuery(BuildNumberCounter.class).disableValidation().field("key").equal(project.getFullName()).get();
if (seq != null) {
getDatastore().delete(seq);
}
}
内容来源于网络,如有侵权,请联系作者删除!