使用Cassandra DB在Scala中映射的问题

时间:2018-12-18 16:04:18

标签: scala cassandra phantom-dsl

我正在尝试连接多个Cassandra表并使用Scala显示它们。 我收到错误消息:

 error: value map is not a member of model.UserMap
       mapResult.map(x => x.map(xx => xx.map(xxx =>

这是我的代码:

import database.UserConnProvider
import database.PhantomUserRepository
import database.PhantomUserMapRepository
import com.softwaremill.macwire._
lazy val cassConn = wire[UserConnProvider]
val user = cassConn

import com.outworkers.phantom.connectors.CassandraConnection
import com.datastax.driver.core._
import com.typesafe.config.ConfigFactory
val connection = user.get()
implicit val session: Session = connection.session
implicit val keySpace = connection.provider.space //provider.space
val config: com.typesafe.config.Config = ConfigFactory.load()
val tableName: String = "map"

import controllers.UserController
import com.outworkers.phantom.connectors.CassandraConnection
import scala.concurrent.{ExecutionContext, Future}

lazy val phantomUserMapRepo = new PhantomUserMapRepository(cassConn.get() , ExecutionContext.Implicits.global)
val userMapRepo = phantomUserMapRepo

import scala.concurrent.ExecutionContext.Implicits.global
import play.api.libs.json._


val mapResult = userMapRepo.findMap("tc")
mapResult.map(x => x.map(xx => xx.map(xxx =>
  for(iter <- xxx.ticker.toArray) {
    println(iter)
  }
)))

数据库定义:

  • 键空间:users
  • 表格:user_infomaptc_codes_map
  • user_info通过map连接到company_code
  • map的{​​{1}}列连接到ticker

将感谢您的提示!

谢谢!

0 个答案:

没有答案