I recently started to work on play & reactive mongo. Referred the reactive mongo documentation to create a SimpleAlbum. When I run the play app I am getting an error like "Implicit modifier cannot be used for top-level objects". Why am I getting this? Help me in resolving the issue. Thanks
package models
import org.joda.time.DateTime
import reactivemongo.bson._
case class SimpleAlbum(
title: String,
releaseYear: Int,
hiddenTrack: Option[String],
allMusicRating: Option[Double])
implicit object SimpleAlbumWriter extends BSONDocumentWriter[SimpleAlbum] {
def write(album: SimpleAlbum): BSONDocument = BSONDocument(
"title" -> album.title,
"releaseYear" -> album.releaseYear,
"hiddenTrack" -> album.hiddenTrack,
"allMusicRating" -> album.allMusicRating)
}
implicit object SimpleAlbumReader extends BSONDocumentReader[SimpleAlbum] {
def read(doc: BSONDocument): SimpleAlbum = {
SimpleAlbum(
doc.getAs[String]("title").get,
doc.getAs[Int]("releaseYear").get,
doc.getAs[String]("hiddenTrack"),
doc.getAs[Double]("allMusicRating"))
}
}
package object
. – Ridglee