Mongodb 存储外部lib';具有ReactiveMongo的对象
我正在尝试使用MongoDB和ReactiveMongo编写一个play2.1应用程序。我的一个模型有一个外部库的成员(特别是securesocialuserid和passwordinfo,但通常是)。 我的问题是-我存储它们的BSON类型是什么Mongodb 存储外部lib';具有ReactiveMongo的对象,mongodb,scala,playframework-2.0,bson,Mongodb,Scala,Playframework 2.0,Bson,我正在尝试使用MongoDB和ReactiveMongo编写一个play2.1应用程序。我的一个模型有一个外部库的成员(特别是securesocialuserid和passwordinfo,但通常是)。 我的问题是-我存储它们的BSON类型是什么 case class User{ firstName: String, lastName: String, authMethod: AuthenticationMethod, avatarUrl: Option[Str
case class User{
firstName: String,
lastName: String,
authMethod: AuthenticationMethod,
avatarUrl: Option[String] = None,
oAuth1Info: Option[OAuth1Info] = None,
oAuth2Info: Option[OAuth2Info] = None,
}
implicit object UserBSONReader extends BSONReader[User] {
def fromBSON(document: BSONDocument) :Role = {
val doc = document.toTraversable
User(
doc.getAs[BSONObjectID]("_id"),
doc.getAs[BSONString]("email").get.value,
doc.getAs[**?????????**]("passwordInfo").get.value,
doc.getAs[BSONString]("firstName").get.value,
doc.getAs[BSONString]("lastName").get.value,
doc.getAs[**?????????**]("authMethod").get.value,
…您只需为这些自定义类型(如UserBSONReader)定义Bson Reader/Writer是的,已经开始这样做了,而且由于选项[]的附加功能,这有点难看。我希望有更优雅的东西(从内部到反应……)