object Windows
Builders for windows used when expressing window output fields. There are two types of windows: documents and range.
Bounded and half-bounded windows require sorting. Window bounds are inclusive and the lower bound must always be less than or equal to the upper bound. The following type-specific rules are applied to windows:
- documents
- bounds
- 0 refers to the current document and is functionally equivalent to CURRENT;
- a negative value refers to documents preceding the current one;
- a positive value refers to documents following the current one;
- bounds
- range
sortBy
(seeAggregates.setWindowFields
)- must contain exactly one field;
- must specify the ascending sort order;
- the
sortBy
field must be of either a numeric BSON type (see the$isNumber
aggregation pipeline stage) or the BSONDate
type if time bounds are used;
- bounds
- if numeric, i.e., not
com.mongodb.client.model.Windows.Bound
, then the bound is calculated by adding the value to the value of thesortBy
field in the current document; - if CURRENT, then the bound is determined by the current document
and not the current value of the
sortBy
field; - time bounds require specifying a time unit and are added as per the
$dateAdd
/$dateSubtract
aggregation pipeline stage specification.
- if numeric, i.e., not
- Annotations
- @Beta()
- Since
4.3
- Note
Requires MongoDB 5.0 or greater.
- See also
- Alphabetic
- By Inheritance
- Windows
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @IntrinsicCandidate()
-
def
documents(lower: Bound, upper: Bound): Window
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed documents window.
-
def
documents(lower: Int, upper: Bound): Window
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed documents window.
-
def
documents(lower: Bound, upper: Int): Window
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed documents window.
- Note
Requires MongoDB 5.0 or greater.
-
def
documents(lower: Int, upper: Int): Window
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
Creates a documents window whose bounds are determined by a number of documents before and after the current document.
- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed documents window.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
def
of(window: Bson): Window
Creates a window from
Bson
in situations when there is no builder method that better satisfies your needs.Creates a window from
Bson
in situations when there is no builder method that better satisfies your needs. This method cannot be used to validate the syntax.Example
The following code creates two functionally identical windows, though they may not be equal.val pastWeek1: Window = Windows.timeRange(-1, MongoTimeUnit.WEEK, Windows.Bound.CURRENT) val pastWeek2: Window = Windows.of( Document("range" -> BsonArray(-1, "current"), "unit" -> BsonString("week")))
- window
A
Bson
representing the required window.- returns
The constructed window.
-
def
range(lower: Decimal128, upper: Bound): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Double, upper: Bound): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Long, upper: Bound): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Bound, upper: Decimal128): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Bound, upper: Double): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Bound, upper: Long): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Decimal128, upper: Decimal128): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Double, upper: Double): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
range(lower: Long, upper: Long): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the value of the
sortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
timeRange(lower: Long, unit: MongoTimeUnit, upper: Bound): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the BSON
Date
value of thesortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the BSON
Date
value of thesortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- unit
A time unit in which
lower
is specified.- upper
A value based on which the upper bound of the window is calculated.
- returns
The constructed range window.
-
def
timeRange(lower: Bound, upper: Long, unit: MongoTimeUnit): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the BSON
Date
value of thesortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the BSON
Date
value of thesortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- unit
A time unit in which
upper
is specified.- returns
The constructed range window.
-
def
timeRange(lower: Long, upper: Long, unit: MongoTimeUnit): Window
Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the BSON
Date
value of thesortBy
field in the current document.Creates a dynamically-sized range window whose bounds are determined by a range of possible values around the BSON
Date
value of thesortBy
field in the current document.- lower
A value based on which the lower bound of the window is calculated.
- upper
A value based on which the upper bound of the window is calculated.
- unit
A time unit in which
lower
andupper
are specified.- returns
The constructed range window.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
object
Bound
Special values that may be used when specifying the bounds of a window.
Special values that may be used when specifying the bounds of a window.
- Annotations
- @Beta()
- Since
4.3
- Note
Requires MongoDB 5.0 or greater.
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated