jstests/aggregation/sources/setWindowFields/count.js
// Run an unpartitioned count query using the window bounds specified as [lower, upper].
Run an unpartitioned count query using the window bounds specified as [lower, upper].
Run an unpartitioned count query using the window bounds specified as [ lower upper ] .
function runCountQuery(lower, upper) {
    return coll
        .aggregate([
            {
                $setWindowFields: {
                    sortBy: {one: 1},
                    output: {a: {$count: {}, window: {documents: [lower, upper]}}}
                }
            },
            {$sort: {_id: 1}}
        ])
        .toArray();
}
function runCountQuery ( lower , upper ) { return coll . aggregate ( [ { $setWindowFields : { sortBy : { one : 1 } , output : { a : { $count : { } , window : { documents : [ lower , upper ] } } } } } , { $sort : { _id : 1 } } ] ) . toArray ( ) ; }
Run an unpartitioned count query using the window bounds specified as [lower, upper].
Run an unpartitioned count query using the window bounds specified as [ lower upper ] .