本文整理汇总了Java中com.mongodb.client.model.BsonField类的典型用法代码示例。如果您正苦于以下问题:Java BsonField类的具体用法?Java BsonField怎么用?Java BsonField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BsonField类属于com.mongodb.client.model包,在下文中一共展示了BsonField类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServerQuery
import com.mongodb.client.model.BsonField; //导入依赖的package包/类
private static List<Bson> getServerQuery(Bson filter) {
final List<Bson> pipeline = new ArrayList<>(6);
if (filter != ALL) {
pipeline.add(Aggregates.match(filter));
}
pipeline.add(Aggregates.unwind("$deployments", new UnwindOptions().preserveNullAndEmptyArrays(true)));
pipeline.add(Aggregates.lookup(Collections.APPLICATIONS, "deployments.applicationId", "id", "applications"));
pipeline.add(Aggregates.unwind("$applications", new UnwindOptions().preserveNullAndEmptyArrays(true)));
pipeline.add(Aggregates.group(
new Document().append("hostname", "$hostname").append("environment", "$environment"),
new BsonField("fqdn", new Document("$first", "$fqdn")),
new BsonField("description", new Document("$first", "$description")),
new BsonField("os", new Document("$first", "$os")),
new BsonField("network", new Document("$first", "$network")),
new BsonField("meta", new Document("$first", "$meta")),
new BsonField("attributes", new Document("$first", "$attributes")),
new BsonField("applications", new Document("$push", "$applications")),
new BsonField("deployments", new Document("$push", "$deployments"))));
pipeline.add(Aggregates.sort(Sorts.ascending("_id")));
return pipeline;
}
示例2: distinct
import com.mongodb.client.model.BsonField; //导入依赖的package包/类
/**
* Add a $group step to filter out redundant solutions.
* @return True if the distinct operation was successfully appended.
*/
public boolean distinct() {
List<String> key = new LinkedList<>();
for (String varName : bindingNames) {
key.add(hashFieldExpr(varName));
}
List<BsonField> reduceOps = new LinkedList<>();
for (String field : FIELDS) {
reduceOps.add(new BsonField(field, new Document("$first", "$" + field)));
}
pipeline.add(Aggregates.group(new Document("$concat", key), reduceOps));
return true;
}
示例3: getAccumulators
import com.mongodb.client.model.BsonField; //导入依赖的package包/类
public List<BsonField> getAccumulators() {
return accumulators;
}
示例4: setAccumulators
import com.mongodb.client.model.BsonField; //导入依赖的package包/类
public MongoAccumulator setAccumulators(List<BsonField> accumulators) {
this.accumulators = accumulators;
return this;
}