当前位置: 首页>>代码示例>>Scala>>正文


Scala PostgresDriver类代码示例

本文整理汇总了Scala中slick.driver.PostgresDriver的典型用法代码示例。如果您正苦于以下问题:Scala PostgresDriver类的具体用法?Scala PostgresDriver怎么用?Scala PostgresDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PostgresDriver类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: MyAPI

//设置package包名称以及导入依赖的类
package support.database



import com.github.tminglei.slickpg.{PgArraySupport, PgDate2Support, PgPlayJsonSupport, _}
import slick.driver.PostgresDriver

trait PvPostgresDriver extends PostgresDriver
  with PgArraySupport
  with PgPlayJsonSupport
  with PgDate2Support
with PgPostGISSupport
with PgSearchSupport {

override val pgjson = "jsonb"
override val api = MyAPI

trait MyImplicits extends JsonImplicits {
  implicit val intListTypeMapper = new SimpleArrayJdbcType[Int]("int4").to(_.toVector)
  implicit val longListTypeMapper = new SimpleArrayJdbcType[Long]("bigint").to(_.toVector)
  implicit val stringListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toVector)

}

object MyAPI extends API
  with ArrayImplicits
  with DateTimeImplicits
  with PostGISImplicits
  with PostGISAssistants
  with PlayJsonImplicits
  with SimpleArrayPlainImplicits
  with PostGISPlainImplicits
  with PlayJsonPlainImplicits
  with Date2DateTimePlainImplicits
with SearchImplicits
with SearchAssistants
with MyImplicits {}

}

object PvPostgresDriver extends PvPostgresDriver 
开发者ID:astahiam,项目名称:pv_,代码行数:42,代码来源:PvPostgresDriver.scala

示例2: StoryTables

//设置package包名称以及导入依赖的类
package dao.story

import com.netaporter.uri.Uri
import slick.driver.PostgresDriver
import dao.BaseTable
import repository.story.{Environment, Scenario, Situation}
import utils.ColumnTypeMapper
import org.joda.time.DateTime



object StoryTables extends {
  val profile = PostgresDriver
} with StoryTables

trait StoryTables extends ColumnTypeMapper {
  val profile: PostgresDriver
  import profile.api._

  class ScenarioTable(tag: Tag) extends BaseTable[Scenario](tag, "scenario") {
    val name: Rep[String] = column[String]("name")
    val description: Rep[String] = column[String]("description")
    val img: Rep[Uri] = column[Uri]("img_src")
    val rating: Rep[Float] = column[Float]("rating")

    def * = (id.?, name, description, img, rating) <> ((Scenario.apply _).tupled, Scenario.unapply)
  }

  lazy val scenarioTable = new TableQuery(tag => new ScenarioTable(tag))

  class SituationTable(tag: Tag) extends BaseTable[Situation](tag, "situation") {
    val idScenario: Rep[Long] = column[Long]("id_scenario")
    val name: Rep[String] = column[String]("name")
    val description: Rep[String] = column[String]("description")
    val place: Rep[String] = column[String]("place")
    val time: Rep[DateTime] = column[DateTime]("time")
    val rating: Rep[Float] = column[Float]("rating")

    def * = (id.?, idScenario, name, description, place, time, rating) <> ((Situation.apply _).tupled, Situation.unapply)
    def userFk = foreignKey("situation_to_scenario_fk", idScenario, scenarioTable)(_.id)
  }

  lazy val situationTable = new TableQuery(tag => new SituationTable(tag))

  class EnvironmentTable(tag: Tag) extends BaseTable[Environment](tag, "environment") {
    val idSituation: Rep[Long] = column[Long]("id_situation")
    val name: Rep[String] = column[String]("name")
    val friendly: Rep[Int] = column[Int]("friendly")
    val unfriendly: Rep[Int] = column[Int]("unfriendly")
    val neutral: Rep[Int] = column[Int]("neutral")
    val rating: Rep[Float] = column[Float]("rating")

    def * = (id.?, idSituation, name, friendly, unfriendly, neutral, rating) <> ((Environment.apply _).tupled, Environment.unapply)
    def userFk = foreignKey("environment_to_situation_fk", idSituation, situationTable)(_.id)
  }

  lazy val environmentTableTable = new TableQuery(tag => new EnvironmentTable(tag))
} 
开发者ID:marius-carp,项目名称:should-i-api,代码行数:59,代码来源:StoryTables.scala

示例3: UserTables

//设置package包名称以及导入依赖的类
package dao.user

import dao.BaseTable
import repository.user.{Gender, User}
import slick.driver.PostgresDriver
import utils.ColumnTypeMapper


object UserTables extends {
  val profile = PostgresDriver
} with UserTables

trait UserTables extends ColumnTypeMapper {
  val profile: PostgresDriver
  import profile.api._

  class UserTable(tag: Tag) extends BaseTable[User](tag, "user") {
    val username: Rep[String] = column[String]("username")
    val gender: Rep[Gender] = column[Gender]("gender")
    val oauthProvider: Rep[String] = column[String]("oauth_provider")
    val oauthUid: Rep[String] = column[String]("oauth_uid")

    def * = (id.?, username, gender, oauthProvider, oauthUid) <> ((User.apply _).tupled, User.unapply)
  }

  lazy val userTable = new TableQuery(tag => new UserTable(tag))
} 
开发者ID:marius-carp,项目名称:should-i-api,代码行数:28,代码来源:UserTables.scala

示例4: database

//设置package包名称以及导入依赖的类
package org.bitcoins.spvnode.constant

import slick.backend.DatabaseConfig
import slick.driver.PostgresDriver
import slick.driver.PostgresDriver.api._


  def database: Database = dbConfig.db
}

trait MainNetDbConfig extends DbConfig {
  override def dbConfig: DatabaseConfig[PostgresDriver] = DatabaseConfig.forConfig("databaseUrl")
}
object MainNetDbConfig extends MainNetDbConfig

trait TestNet3DbConfig extends DbConfig {
  override def dbConfig: DatabaseConfig[PostgresDriver] = DatabaseConfig.forConfig("testNet3DatabaseUrl")
}
object TestNet3DbConfig extends TestNet3DbConfig


trait RegTestDbConfig extends DbConfig {
  override def dbConfig: DatabaseConfig[PostgresDriver] = DatabaseConfig.forConfig("regTestDatabaseUrl")
}
object RegTestDbConfig extends RegTestDbConfig 
开发者ID:bitcoin-s,项目名称:bitcoin-s-spv-node,代码行数:26,代码来源:DbConfig.scala

示例5: JdbcProfileProvider

//设置package包名称以及导入依赖的类
package au.com.agiledigital.dao.slick

import slick.driver.{ DerbyDriver, H2Driver, HsqldbDriver, JdbcProfile, MySQLDriver, PostgresDriver, SQLiteDriver }

trait JdbcProfileProvider {
  type JP <: JdbcProfile
  val driver: JP
}

object JdbcProfileProvider {

  trait H2ProfileProvider extends JdbcProfileProvider {
    type JP = H2Driver
    val driver: H2Driver = H2Driver
  }

  trait PostgresProfileProvider extends JdbcProfileProvider {
    type JP = PostgresDriver
    val driver = PostgresDriver
  }

  trait DerbyProfileProvider extends JdbcProfileProvider {
    type JP = DerbyDriver
    val driver = DerbyDriver
  }

  trait HsqlProfileProvider extends JdbcProfileProvider {
    type JP = HsqldbDriver
    val driver = HsqldbDriver
  }

  trait MySQLProfileProvider extends JdbcProfileProvider {
    type JP = MySQLDriver
    val driver = MySQLDriver
  }

  trait SQLLiteProfileProvider extends JdbcProfileProvider {
    type JP = SQLiteDriver
    val driver = SQLiteDriver
  }

} 
开发者ID:agiledigital,项目名称:slick-dao,代码行数:43,代码来源:JdbcProfileProvider.scala


注:本文中的slick.driver.PostgresDriver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。