scalacassandraphantom-dsl

Cassandra Phantom - could not find implicit value for parameter helper: com.outworkers.phantom.macros.TableHelper[Users, User]


I am using Cassandra Phantom driver to build an application with Scala and Cassandra. My code looks like this:

case class User(id: UUID, name:String)

abstract class Users extends CassandraTable[Users, User] with RootConnector {
  object id extends UUIDColumn(this) with PartitionKey
  object name extends StringColumn(this)

  def save(user: User): Future[ResultSet] = {
    insert
      .value(_.id, user.id)
      .value(_.name, user.name)
      .consistencyLevel_=(ConsistencyLevel.ALL)
      .future()
  }

  def getById(id: UUID): Future[Option[User]] = {
    select.where(_.id eqs id).one()
  }
}

But when I try to compile the code it gives me following error:

could not find implicit value for parameter helper: com.outworkers.phantom.macros.TableHelper[Users, User]

I am not able to understand why this error is occurring when I am following documentation.

Phantom Version: 2.7.6

Scala: 2.11.2


Solution

  • case class User(id: UUID, name:String)
    
    abstract class Users extends Table[Users, User] with RootConnector {
      object id extends UUIDColumn(this) with PartitionKey
      object name extends StringColumn(this)
    
      def save(user: User): Future[ResultSet] = {
        store(user)
          .consistencyLevel_=(ConsistencyLevel.ALL)
          .future()
      }
    
      def getById(id: UUID): Future[Option[User]] = {
        select.where(_.id eqs id).one()
      }
    }
    

    I have just compiled this with 2.7.6, you also don't need to manually implement an insert as it is generated for you.