问题描述:

I have couple simple classes:

 class Address(street: String)

class Person(name: String, addresses: List[Address])

How can I save it in MongoDB? And I want to use wrap/unwrap operation after saving operations.

When I try to use casbah API I have got the exception like this:

 MongoFactory.testCollection.save(Person("Name", List(Address("Street"))))

Exception in thread "main" org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class mongo.MongoTest$Person2.

网友答案:

Yo can use ReactiveMongo for this purpose. If you want to use play-json directly instead of BSON, you could use ReactiveMongo play extension.

相关阅读:
Top