use of dev.morphia.query.Sort in project morphia by mongodb.
the class AggregationPipelineImpl method sort.
@Override
public AggregationPipeline sort(Sort... sorts) {
Document sortList = new Document();
for (Sort sort : sorts) {
sortList.put(sort.getField(), sort.getOrder());
}
stages.add(new Document("$sort", sortList));
return this;
}
use of dev.morphia.query.Sort in project morphia by mongodb.
the class SetWindowFieldsCodec method encodeStage.
@Override
protected void encodeStage(BsonWriter writer, SetWindowFields value, EncoderContext encoderContext) {
document(writer, () -> {
if (value.partition() != null) {
writer.writeName("partitionBy");
expression(getDatastore(), writer, value.partition(), encoderContext);
}
Sort[] sorts = value.sorts();
if (sorts != null) {
document(writer, "sortBy", () -> {
for (Sort sort : sorts) {
writer.writeInt64(sort.getField(), sort.getOrder());
}
});
}
document(writer, "output", () -> {
for (Output output : value.outputs()) {
document(writer, output.name(), () -> {
operator(writer, encoderContext, output.operator());
window(writer, output, encoderContext);
});
}
});
});
}