Skip to content

Instantly share code, notes, and snippets.

@switzer
Created December 5, 2012 18:57
Show Gist options
  • Save switzer/4218450 to your computer and use it in GitHub Desktop.
Save switzer/4218450 to your computer and use it in GitHub Desktop.
Customer Serializer
implicit object CustomerSerializer extends CasbahSerializer[Customer] {
def apply(customer: Customer) = {
val builder = MongoDBObject.newBuilder
System.out.println("CustomerSerializer:::" + customer)
builder += "firstName" -> customer.firstName
builder += "lastName" -> customer.lastName
builder += "email" -> customer.email
builder += "addresses" -> customer.addresses.map(AddressSerializer(_))
builder += "id" -> customer.id
builder.result()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment