如何在集合中传递不同的值

how to pass different values in a collection

我正在使用此代码https://github.com/alvinj/ScalaCasbahConnections/blob/master/src/main/scala/casbahtests/MongoFactory.scala

object MongoFactory {

  private val SERVER = "localhost"
  private val PORT   = 27017
  private val DATABASE = "finance"
  private val COLLECTION = "stocks"

  val connection = MongoConnection(SERVER)
  val collection = connection(DATABASE)(COLLECTION)

}

但是在此代码中,COLLECTION val 具有 "stocks" 值意味着它只有一个值,如果我想使用不同的集合名称值,我该如何修改此代码以支持不同的集合名称,请帮忙

我猜它一定有用:

def collection(name : String) = connection(DATABASE)(name)