over method

WindowFunction over(
  1. WindowFrame frame
)

This aggregate evaluated over frame, relative to each input, instead of over the frame of the enclosing Pipeline.addWindowFields stage.

pipeline.addWindowFields(
  WindowSpec(sort: [field('date').ascending()]),
  [
    field('amount')
        .average()
        .over(WindowFrame.documents(preceding: 1, following: 1))
        .as('movingAverage'),
  ],
);

Beta: window functions are a preview feature of the server.

Implementation

WindowFunction over(WindowFrame frame) =>
    WindowFunction.withFrame(name, args, frame);