Only get name and lastname?

9 views
Skip to first unread message

Michael Larsson

unread,
Apr 25, 2013, 3:47:16 AM4/25/13
to scala...@googlegroups.com
Hi.
How will I only get the firstname and lastname from a collection that contains address, phone and so on?

Ex:

EventDAO(language).find(MongoDBObject("id"-> new ObjectId(id))).toList

/Thanks

Eduardo Obando

unread,
Apr 30, 2013, 12:00:57 PM4/30/13
to scala...@googlegroups.com
EventDAO(language).find(MongoDBObject("id"-> new ObjectId(id)), MongoDBObject("firstname" -> 1, "lastname" -> 1)).toList

But you need to make sure that the address, phone and others has a default, otherwise it would throw an exception.

case class Event(firstname: String, lastname: String, address: String = "", phone: String = "")
Reply all
Reply to author
Forward
0 new messages