Created
April 12, 2011 10:10
-
-
Save bruntonspall/915282 to your computer and use it in GitHub Desktop.
This morning I turned ugly.scala into better.scala - still looking for a best.scala though
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val optContacts = person.expand[BasicDBList]("contacts.pending") | |
for { | |
contacts <- optContacts; | |
contact <- contacts | |
if contact.isInstanceOf[DBObject] | |
pendingContact = contact.asInstanceOf[DBObject] | |
if pendingContact.expand[String]("contactId").get == contactId | |
} { | |
// Do stuff on contact and update mongo | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
person.expand[BasicDBList]("contacts.pending") map { contacts => | |
contacts map { contact => | |
contact match { | |
case pendingContact:DBObject => { | |
if (pendingContact.expand[String]("contactId").get == contactId) { | |
// Do stuff on contact and update mongo | |
} | |
} | |
case _ => | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment