本文整理匯總了Java中com.mongodb.client.model.Filters.and方法的典型用法代碼示例。如果您正苦於以下問題:Java Filters.and方法的具體用法?Java Filters.and怎麽用?Java Filters.and使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.mongodb.client.model.Filters
的用法示例。
在下文中一共展示了Filters.and方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: between
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
default Bson between() {
return Filters.and(
Filters.gte("millis", millis()[0]),
Filters.lte("millis", millis()[1])
);
}
示例2: filter
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
@Override
public Bson filter() {
List<Bson> filters = Stream.of(
between(),
filter("caller", caller),
filter("callee", callee)
).filter(Objects::nonNull).collect(Collectors.toList());
return Filters.and(filters);
}
示例3: filter
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
@Override
public Bson filter() {
return Filters.and(
between(),
Filters.in("call_id", callIds)
);
}
示例4: and
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
/**
* 與操作
*
* @param queries
* @return
*/
public static MongodbQuery and(MongodbQuery... queries) {
List<Bson> queryList = new ArrayList<Bson>();
for (MongodbQuery query : queries) {
if (query != null && query.getQuery() != null) {
queryList.add(query.getQuery());
}
}
return new MongodbQuery(Filters.and(queryList));
}
示例5: testDeleteById
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
@Test
public void testDeleteById() {
TestMongo testMongo = new TestMongo("222", "name");
boolean result = MongodbManager.insertOne("test_table", testMongo);
Bson filter = Filters.and(Filters.eq("id", "222"));
List<TestMongo> list = MongodbManager.find("test_table", filter, TestMongo.class, 0, 0);
testMongo = list.get(0);
result = MongodbManager.deleteById("test_table", testMongo);
assertEquals(true, result);
}
示例6: testUpdateById
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
@Test
public void testUpdateById() {
TestMongo testMongo = new TestMongo("333", "name");
boolean result = MongodbManager.insertOne("test_table", testMongo);
Bson filter = Filters.and(Filters.eq("id", "333"));
List<TestMongo> list = MongodbManager.find("test_table", filter, TestMongo.class, 0, 0);
testMongo = list.get(0);
testMongo.setName("name" + UUID.randomUUID().toString());
result = MongodbManager.updateById("test_table", testMongo);
assertEquals(true, result);
}
示例7: getChatList
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
public static List<ChatObj> getChatList(String fromUserId, String toTypeId, int chatType) {
Bson filter = Filters.and(Filters.eq(ChatObj.FROM_USER_ID, fromUserId), Filters.eq(ChatObj.CHAT_TYPE, chatType));
List<ChatObj> list = MongodbManager.find(getUserToUserCollectionName(fromUserId, toTypeId), filter, ChatObj.class, 0, 0);
return list;
}
示例8: get
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
@Override
public Bson get() {
List<Predicate> predicates = getPredicates();
List<Bson> filters = Lists.newArrayListWithExpectedSize(predicates.size());
for (Predicate predicate : predicates) {
if (predicate.isEquals()) {
filters.add(Filters.eq(predicate.getLhs(), toOperand(predicate.getRhs().get(0))));
} else if (predicate.isNotEquals()) {
filters.add(Filters.ne(predicate.getLhs(), toOperand(predicate.getRhs().get(0))));
} else if (predicate.isGreaterThan()) {
filters.add(Filters.gt(predicate.getLhs(), toOperand(predicate.getRhs().get(0))));
} else if (predicate.isGreaterThanOrEqualTo()) {
filters.add(Filters.gte(predicate.getLhs(), toOperand(predicate.getRhs().get(0))));
} else if (predicate.isLessThan()) {
filters.add(Filters.lt(predicate.getLhs(), toOperand(predicate.getRhs().get(0))));
} else if (predicate.isLessThanOrEqualTo()) {
filters.add(Filters.lte(predicate.getLhs(), toOperand(predicate.getRhs().get(0))));
} else if (predicate.isBetween()) {
// 'x between 5 and 10' _generally_ means: x >= 5 and x < 10
filters.add(Filters.gte(predicate.getLhs(), toOperand(predicate.getRhs().get(0))));
filters.add(Filters.lt(predicate.getLhs(), toOperand(predicate.getRhs().get(1))));
} else if (predicate.isIn()) {
filters.add(Filters.in(predicate.getLhs(), toOperands(predicate.getRhs())));
} else if (predicate.isNotIn()) {
filters.add(Filters.nin(predicate.getLhs(), toOperands(predicate.getRhs())));
} else if (predicate.isLike()) {
filters.add(Filters.regex(predicate.getLhs(), toRegex(predicate.getRhs().get(0))));
} else if (predicate.isNotLike()) {
filters.add(
Filters.not(Filters.regex(predicate.getLhs(), toRegex(predicate.getRhs().get(0)))));
} else if (predicate.isNull()) {
filters.add(Filters.eq(predicate.getLhs(), null));
} else if (predicate.isNotNull()) {
filters.add(Filters.ne(predicate.getLhs(), null));
}
}
if (filters.isEmpty()) {
// this is the no-op case
return new BsonDocument();
} else {
return Filters.and(filters.toArray(new Bson[filters.size()]));
}
}
示例9: filter
import com.mongodb.client.model.Filters; //導入方法依賴的package包/類
private Bson filter(String name, String hashedPassword) {
return Filters.and(Filters.eq("name", name), Filters.eq("hashedPassword", hashedPassword));
}