Montage
1.0

Transformation

With fields

Exclude documents that do not have the specified fields and return only those fields.

Functionally, this is identical to has_fields followed by pluck.

Query('movies').with_fields('name', 'year', 'rating')

Functionally, this is identical to hasFields followed by pluck.

new Query('movies').withFields('name', 'year', 'rating')

Has fields

Test if a document has the specified fields, filtering out any that do not.

Query('movies').has_fields('name', 'year', 'rating')
new Query('movies').hasFields('name', 'year', 'rating')

Order by

Sort the documents by the specified field.

Query('movies').order_by('year')
new Query('movies').orderBy('year')

Limit

End the sequence after the givin number of documents

Query('movies').limit(10)
new Query('movies').limit(10)

Slice

Return the documents within the specified range

Query('movies').slice(5, 15)
new Query('movies').slice(5, 15)

Nth

Get the nth document in the sequence

Query('movies').nth(7)
new Query('movies').nth(7)

Sample

Select a given number of elements from a sequence with uniform random distribution

Query('movies').sample(10)
new Query('movies').sample(10)