File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
main/scala/org/mongodb/scala/model
test/scala/org/mongodb/scala/model Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -339,11 +339,21 @@ object Aggregates {
339
339
def unwind (fieldName : String , unwindOptions : UnwindOptions ): Bson = JAggregates .unwind(fieldName, unwindOptions)
340
340
341
341
/**
342
- * Creates a `\$out` pipeline stage for the specified filter
342
+ * Creates a `\$out` pipeline stage that writes to the collection with the specified name
343
343
*
344
344
* @param collectionName the collection name
345
345
* @return the `\$out` pipeline stage
346
346
* @see [[http://docs.mongodb.org/manual/reference/operator/aggregation/out/ \$out ]]
347
347
*/
348
348
def out (collectionName : String ): Bson = JAggregates .out(collectionName)
349
+
350
+ /**
351
+ * Creates a `\$out` pipeline stage that writes to the collection with the specified name, using the specified options
352
+ *
353
+ * @param collectionName the collection name
354
+ * @param options the options
355
+ * @return the `\$out` pipeline stage
356
+ * @see [[http://docs.mongodb.org/manual/reference/operator/aggregation/out/ \$out ]]
357
+ */
358
+ def out (collectionName : String , options : AggregateOutStageOptions ): Bson = JAggregates .out(collectionName, options)
349
359
}
Original file line number Diff line number Diff line change @@ -79,6 +79,22 @@ package object model {
79
79
def apply (): BucketOptions = new com.mongodb.client.model.BucketOptions ()
80
80
}
81
81
82
+ /**
83
+ * The options for a \$out aggregation pipeline stage
84
+ *
85
+ * @since 2.6
86
+ */
87
+ type AggregateOutStageOptions = com.mongodb.client.model.AggregateOutStageOptions
88
+
89
+ /**
90
+ * The options for a \$out aggregation pipeline stage
91
+ *
92
+ * @since 2.6
93
+ */
94
+ object AggregateOutStageOptions {
95
+ def apply (): AggregateOutStageOptions = new com.mongodb.client.model.AggregateOutStageOptions ()
96
+ }
97
+
82
98
/**
83
99
* Granularity values for automatic bucketing.
84
100
*
Original file line number Diff line number Diff line change @@ -200,6 +200,9 @@ class AggregatesSpec extends FlatSpec with Matchers {
200
200
201
201
it should " render $out" in {
202
202
toBson(out(" authors" )) should equal(Document (""" { $out : "authors" }""" ))
203
+ toBson(out(" authors" , AggregateOutStageOptions ().databaseName(" foo" ))) should equal(
204
+ Document (""" { $out : {mode: "replaceCollection", to: "authors", db: "foo" } }""" )
205
+ )
203
206
}
204
207
205
208
it should " render $group" in {
You can’t perform that action at this time.
0 commit comments