Permalink
Browse files

Allow sort-like K/V Pair lists to project

  • Loading branch information...
1 parent 3c00e31 commit a20225fa874de8fc1ff41a51bb96be50653bbedc @bwmcadams bwmcadams committed Nov 5, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 casbah-query/src/main/scala/aggregation/Project.scala
View
6 casbah-query/src/main/scala/aggregation/Project.scala
@@ -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

0 comments on commit a20225f

Please sign in to comment.