本文整理了Java中com.mongodb.client.model.Filters.in()
方法的一些代码示例,展示了Filters.in()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filters.in()
方法的具体详情如下:
包路径:com.mongodb.client.model.Filters
类名称:Filters
方法名:in
Filters.in介绍
[英]Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
[中]创建一个筛选器,该筛选器匹配字段值等于指定值列表中任何值的所有文档。
代码示例
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
*
* @param fieldName the field name
* @param values the list of values
* @param the value type
* @return the filter
* @mongodb.driver.manual reference/operator/query/in $in
*/
public static Bson in(final String fieldName, final TItem... values) {
return in(fieldName, asList(values));
}
代码示例来源:origin: eclipse/ditto
@Override
public Function visitIn(final List> values) {
return fieldName -> Filters.in(fieldName, values);
}
代码示例来源:origin: org.mongodb/mongodb-driver-core
/**
* Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
*
* @param fieldName the field name
* @param values the list of values
* @param the value type
* @return the filter
* @mongodb.driver.manual reference/operator/query/in $in
*/
public static Bson in(final String fieldName, final TItem... values) {
return in(fieldName, asList(values));
}
代码示例来源:origin: epam/DLab
/**
* Add the conditions to the list.
*
* @param conditions the list of conditions.
* @param fieldName the name of field.
* @param values the values.
*/
private void addCondition(List conditions, String fieldName, List values) {
if (values != null && !values.isEmpty()) {
conditions.add(in(fieldName, values));
}
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@Override
public void deleteAll(Collection keys) {
this.collection.deleteMany(in("_id", keys));
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-mongodb
@Override
public List readStates(List ids) {
return findAll(Filters.in(idKey, ids));
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-mongodb
@Override
public void deleteStates(Set ids) {
Bson filter = Filters.in(idKey, ids);
if (log.isTraceEnabled()) {
log.trace("MongoDB: REMOVE " + ids);
}
DeleteResult w = coll.deleteMany(filter);
if (w.getDeletedCount() != ids.size()) {
if (log.isDebugEnabled()) {
log.debug("Removed " + w.getDeletedCount() + " docs for " + ids.size() + " ids: " + ids);
}
}
}
代码示例来源:origin: com.holon-platform.mongo/holon-datastore-mongo-core
@Override
public BsonFilterExpression visit(InFilter filter, MongoResolutionContext> context) {
return resolveOperationQueryFilter(context, filter,
(c, fn) -> Filters.in(fn, resolveRightOperandAsIterable(filter, context)));
}
代码示例来源:origin: sip3io/tapir
@Override
public Bson filter() {
return Filters.and(
between(),
Filters.in("call_id", callIds)
);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@Override
public Map loadAll(Collection keys) {
System.out.println("LoadAll " + keys);
HashMap result = new HashMap();
FindIterable id = collection.find(in("_id", keys));
for (Document document : id) {
String name = (String) document.get("name");
Integer price = document.getInteger("price");
result.put(document.get("_id").toString(), new Supplement(name, price));
}
return result;
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
@Override
public Single> findByIdIn(List ids) {
return Observable.fromPublisher(groupsCollection.find(in(FIELD_ID, ids))).map(this::convert).collect(ArrayList::new, List::add);
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
@Override
public Single> findByIdIn(List ids) {
return Observable.fromPublisher(usersCollection.find(in(FIELD_ID, ids))).map(this::convert).collect(ArrayList::new, List::add);
}
代码示例来源:origin: epam/DLab
private Bson computationalFilter(String user, String exploratoryName, String computationalStatus, String
computationalImage, UserInstanceStatus[] excludedStatuses) {
final String[] statuses = Arrays.stream(excludedStatuses)
.map(UserInstanceStatus::toString)
.toArray(String[]::new);
return and(exploratoryCondition(user, exploratoryName),
elemMatch(COMPUTATIONAL_RESOURCES, and(eq(IMAGE, computationalImage),
not(in(STATUS, statuses)),
not(eq(STATUS, computationalStatus)))));
}
代码示例来源:origin: epam/DLab
protected Optional getEdgeInfoWhereStatusIn(String user, Class target,
UserInstanceStatus... statuses) {
return findOne(USER_EDGE,
and(eq(ID, user), in(EDGE_STATUS, statusList(statuses))),
target);
}
代码示例来源:origin: epam/DLab
public boolean edgeNodeExist(String user) {
return findOne(USER_EDGE, and(eq(ID, user), not(in(EDGE_STATUS, UserInstanceStatus.TERMINATING.toString(),
UserInstanceStatus.TERMINATED.toString()))))
.isPresent();
}
代码示例来源:origin: de.otto.edison/edison-mongo
@Override
public List findLatestJobsDistinct() {
final List allJobIds = findAllJobIdsDistinct();
return collection()
.find(Filters.in(ID, allJobIds))
.maxTime(mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS)
.map(this::decode)
.into(new ArrayList<>());
}
代码示例来源:origin: otto-de/edison-microservice
@Override
public List findLatestJobsDistinct() {
final List allJobIds = findAllJobIdsDistinct();
return collection()
.find(in(ID, allJobIds))
.maxTime(mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS)
.map(this::decode)
.into(new ArrayList<>());
}
代码示例来源:origin: de.bwaldvogel/mongo-java-server-test-common
@Test
public void testPullWithInPattern() {
collection.insertOne(json("_id: 1, tags: ['aa', 'bb', 'ab', 'cc']"));
collection.updateOne(json("_id: 1"), pullByFilter(in("tags", Pattern.compile("a+"))));
assertThat(collection.find().first()).isEqualTo(json("_id: 1, tags: ['bb', 'cc']"));
}
代码示例来源:origin: de.bwaldvogel/mongo-java-server-test-common
@Test
public void testPullWithInPatternAnchored() {
collection.insertOne(json("_id: 1, tags: ['aa', 'bb', 'ab', 'cc']"));
collection.updateOne(json("_id: 1"), pullByFilter(in("tags", Pattern.compile("^a+$"))));
assertThat(collection.find().first()).isEqualTo(json("_id: 1, tags: ['bb', 'ab', 'cc']"));
}
代码示例来源:origin: de.bwaldvogel/mongo-java-server-test-common
@Test
public void testPullWithInNumbers() {
collection.insertOne(json("_id: 1, values: [1, 2, 2.5, 3.0, 4]"));
collection.updateOne(json("_id: 1"), pullByFilter(in("values", Arrays.asList(2.0, 3, 4L))));
assertThat(collection.find().first()).isEqualTo(json("_id: 1, values: [1, 2.5]"));
}