Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow sort-like K/V Pair lists to project

  • Loading branch information...
commit a20225fa874de8fc1ff41a51bb96be50653bbedc 1 parent 3c00e31
Brendan W. McAdams bwmcadams authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 casbah-query/src/main/scala/aggregation/Project.scala
6 casbah-query/src/main/scala/aggregation/Project.scala
View
@@ -35,6 +35,12 @@ trait ProjectOperator extends PipelineOperator {
// TODO - Validate only valid field entries?
def $project(target: DBObject) = op(operator, target)
+
+ def $project(fields: (String, Int)*) = {
+ val bldr = MongoDBObject.newBuilder
+ for ((k, v) <- fields) bldr += k -> v
+ op(operator, bldr.result)
+ }
}
trait ProjectSubOperators extends ProjectAndBooleanOperator
Please sign in to comment.
Something went wrong with that request. Please try again.