• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Tag类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: User

//设置package包名称以及导入依赖的类
package models

import java.util.Date

import slick.driver.PostgresDriver.api._
import slick.lifted.Tag

case class User(
  id: Option[Long],
  firstName: String,
  lastName: String,
  fullName: String,
  age: Int,
  active: Boolean
)

class Users(tag: Tag) extends Table[User](tag, "user") {
  implicit val dateColumnType = MappedColumnType.base[Date, Long](d => d.getTime, d => new Date(d))

  def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
  def firstName = column[String]("firstName")
  def lastName = column[String]("lastName")
  def fullName = column[String]("fullName")
  def age = column[Int]("age")
  def active = column[Boolean]("active")

  override def * = (id.?, firstName, lastName, fullName, age, active) <> (User.tupled, User.unapply)
} 
开发者ID:cloudwicklabs,项目名称:play-cloudwickone-slick-template,代码行数:29,代码来源:User.scala


示例2: Friend

//设置package包名称以及导入依赖的类
package net.scalax.fsn.database.test

import slick.jdbc.H2Profile.api._
import slick.lifted.Tag

case class Friend(
  id: Option[Long] = None,
  name: String,
  nick: String,
  age: Option[Int],
  grade: Int
)

class FriendTable(tag: Tag) extends Table[Friend](tag, "friend") {
  def id = column[Long]("id", O.AutoInc)
  def name = column[String]("name")
  def nick = column[String]("nick")
  def age = column[Option[Int]]("age")
  def grade = column[Int]("grade")

  def * = (id.?, name, nick, age, grade).mapTo[Friend]
}

object FriendTable extends TableQuery(cons => new FriendTable(cons))

class SimpleTable(tag: Tag, tbName: String) extends Table[Unit](tag, tbName) {
  def * = ()
}

object SimpleTable {

  def tq(tbName: String): TableQuery[SimpleTable] = {
    TableQuery(cons => new SimpleTable(cons, tbName))
  }

} 
开发者ID:scalax,项目名称:ubw,代码行数:37,代码来源:Models.scala


示例3: StickerPackTable

//设置package包名称以及导入依赖的类
package im.actor.server.persist

import slick.lifted.Tag
import im.actor.server.db.ActorPostgresDriver.api._
import im.actor.server.model.StickerPack

class StickerPackTable(tag: Tag) extends Table[StickerPack](tag, "sticker_packs") {
  def id = column[Int]("id", O.PrimaryKey)
  def accessSalt = column[String]("access_salt")
  def ownerUserId = column[Int]("owner_user_id")
  def isDefault = column[Boolean]("is_default")

  def * = (id, accessSalt, ownerUserId, isDefault) <> (StickerPack.tupled, StickerPack.unapply)
}

object StickerPackRepo {
  val stickerPacks = TableQuery[StickerPackTable]

  def create(pack: StickerPack) =
    stickerPacks += pack

  def setDefault(packId: Int, isDefault: Boolean): DBIO[Int] =
    stickerPacks.filter(_.id === packId).map(_.isDefault).update(isDefault)

  def findByOwner(userId: Int): DBIO[Seq[StickerPack]] =
    stickerPacks.filter(_.ownerUserId === userId).result

  def exists(userId: Int, packId: Int): DBIO[Boolean] =
    stickerPacks.filter(p ? (p.id === packId) && (p.ownerUserId === userId)).exists.result

  def exists(packId: Int): DBIO[Boolean] =
    stickerPacks.filter(_.id === packId).exists.result

  def find(id: Int) = stickerPacks.filter(_.id === id).result.headOption

  def find(ids: Seq[Int], withDefault: Boolean = true): DBIO[Seq[StickerPack]] =
    (if (withDefault)
      stickerPacks.filter(p ? p.isDefault || (p.id inSet ids.toSet))
    else
      stickerPacks.filter(p ? p.id inSet ids)).result
} 
开发者ID:wex5,项目名称:dangchat-server,代码行数:42,代码来源:StickerPackRepo.scala


示例4: Suppliers

//设置package包名称以及导入依赖的类
package chehao.myscala.slick

import slick.driver.H2Driver.api._
import slick.lifted.Tag
import slick.lifted.{ProvenShape, ForeignKeyQuery}

class Suppliers(tag: Tag) extends Table[(Int, String, String, String, String, String)](tag, "SUPPLIERS") {  
  // This is the primary key column:
  def id: Rep[Int] = column[Int]("SUP_ID", O.PrimaryKey)
  def name: Rep[String] = column[String]("SUP_NAME")
  def street: Rep[String] = column[String]("STREET")
  def city: Rep[String] = column[String]("CITY")
  def state: Rep[String] = column[String]("STATE")
  def zip: Rep[String] = column[String]("ZIP")
  
  // Every table needs a * projection with the same type as the table's type parameter
  def * : ProvenShape[(Int, String, String, String, String, String)] =
    (id, name, street, city, state, zip)
} 
开发者ID:Chehao,项目名称:Akkala,代码行数:20,代码来源:Suppliers.scala


示例5: Region

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

import scala.concurrent._
import scala.concurrent.duration._
import javax.inject.Inject
import play.api.Play
import javax.inject._
import play.api.libs.concurrent.Execution.Implicits._
import slick.lifted.Tag
import slick.driver.MySQLDriver.api._


case class Region(regionName:String, regionId:Option[Int] = None)

class Regions(tag:Tag) extends Table[Region](tag, "regions") {
  def regionId = column[Int]("regionId", O.PrimaryKey, O.AutoInc)
  def regionName = column[String]("regionName")
  def * = (regionName, regionId.?)<>((Region.apply _).tupled, Region.unapply)
}
object Regions {

  val db = Database.forConfig("h2mem1")
  lazy val regionTable = TableQuery[Regions]
  
  def regionName(regionId:Int):Option[Region] ={
    val rName = Await.result(db.run(regionTable.filter(_.regionId === regionId).result), Duration.Inf)
    if(rName.isEmpty) None else Some(rName.head)
  }
} 
开发者ID:joke1196,项目名称:HolyJobs,代码行数:30,代码来源:Region.scala


示例6: Type

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

import scala.concurrent._
import scala.concurrent.duration._
import javax.inject.Inject
import play.api.Play
import javax.inject._
import play.api.libs.concurrent.Execution.Implicits._
import slick.lifted.Tag
import slick.driver.MySQLDriver.api._


case class Type(typeName:String, typeId:Option[Int] = None)

class Types(tag:Tag) extends Table[Type](tag, "types") {
  def typeId = column[Int]("typeId", O.PrimaryKey, O.AutoInc)
  def typeName = column[String]("typeName")
  def * = (typeName, typeId.?)<>((Type.apply _).tupled, Type.unapply)
}
object Types {

  val db = Database.forConfig("h2mem1")
  lazy val typeTable = TableQuery[Types]
  
  def typeName(typeId:Int):Option[Type] ={
    val tName = Await.result(db.run(typeTable.filter(_.typeId === typeId).result), Duration.Inf)
    if(tName.isEmpty) None else Some(tName.head)
  }
} 
开发者ID:joke1196,项目名称:HolyJobs,代码行数:30,代码来源:Type.scala


示例7: Job

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

import scala.concurrent._
import scala.concurrent.duration._
import javax.inject.Inject
import play.api.Play
import javax.inject._
import play.api.libs.concurrent.Execution.Implicits._
import slick.lifted.Tag
import slick.driver.MySQLDriver.api._


import java.sql.Date

case class Job(name: String, description:String, startDate: Date, endDate:Date,jobType:Int, region:Int, hourlyPay:Double, workingTime:Int, email:String, img:Option[String] = None, id: Option[Int] = None)
// The representation of the Table jobs in the database
class Jobs(tag: Tag) extends Table[Job](tag, "jobs") {
  def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
  def name = column[String]("name")
  def description = column[String]("description")
  def startDate = column[Date]("startDate")
  def endDate = column[Date]("endDate")
  def jobType = column[Int]("jobType")
  def region = column[Int]("region")
  def hourlyPay = column[Double]("hourlyPay")
  def workingTime = column[Int]("workingTime")
  def email = column[String]("email")
  def img = column[String]("img")
  def typeId = foreignKey("typeId", jobType, Types.typeTable)(_.typeId)
  def regionId = foreignKey("regionId", region, Regions.regionTable)(_.regionId)

  def * = (name, description, startDate, endDate, jobType, region, hourlyPay, workingTime, email,img.?, id.?)<>((Job.apply _).tupled, Job.unapply)
}

object Jobs {
  val db = Database.forConfig("h2mem1")
  val jobTable = TableQuery[Jobs]

  
  def filteredJobs(jobType: Int, region:Int, startDate:Date):List[Job] = {
    val query = (jobType, region, startDate) match {
        case (j, r, d) if(j < 0 && r >= 0) => jobTable.filter(_.region === r).filter(_.startDate <= d).filter(_.endDate >= startDate)
        case (j, r, d) if( r < 0 && j >= 0) => jobTable.filter(_.jobType === j).filter(_.startDate <= d).filter(_.endDate >= startDate)
        case (j, r, d) if(r < 0 && j < 0) => jobTable.filter(_.startDate <= d).filter(_.endDate >= startDate)
        case (j, r, d) => jobTable.filter(_.jobType === j).filter(_.region === r).filter(_.startDate <= d).filter(_.endDate >= startDate)
    }
    val job = for(j <- Await.result(db.run(query.result), Duration.Inf)) yield j
    job.toList
  }

} 
开发者ID:joke1196,项目名称:HolyJobs,代码行数:52,代码来源:Job.scala


示例8: StoredObjectTable

//设置package包名称以及导入依赖的类
package com.waltsu.wdht.storage.tables

import com.waltsu.wdht.storage.models.StoredObject
import slick.driver.SQLiteDriver.api._
import slick.lifted.Tag

object StoredObjectTable {
  val storedObjects = TableQuery[StoredObjectTable]

  def returningStoredObjects = (storedObjects returning storedObjects.map(_.id)) into ((`object`, id) => `object`.copy(id=id))

}
class StoredObjectTable(tag: Tag) extends Table[StoredObject](tag, "objects") {
  def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
  def key = column[String]("key")
  def value = column[String]("value")

  def * = (id, key, value) <> ((StoredObject.apply _).tupled, StoredObject.unapply)
} 
开发者ID:waltsu,项目名称:wdht,代码行数:20,代码来源:StoredObjectTable.scala


示例9: DAO

//设置package包名称以及导入依赖的类
import cog.ty.scraper.{Challenge, Difficulty, Response, User}
import slick.lifted.{ProvenShape, Tag}
import slick.jdbc.JdbcProfile
import java.util.Date
import java.net.URL

class DAO(driver: JdbcProfile) {
  import driver.api._

  class Users(tag: Tag) extends Table[User](tag, "USERS") {
    def username = column[String]("USERNAME", O.PrimaryKey)
    override def * : ProvenShape[User] = username <> (User.apply, User.unapply)
  }
  val users = TableQuery[Users]

  class Challenges(tag: Tag) extends Table[Challenge](tag, "CHALLENGES") {
    def id = column[String]("ID", O.PrimaryKey)
    def created = column[Date]("CREATED")
    def link = column[String]("LINK")
    def title = column[String]("TITLE")
    def body = column[String]("BODY")
    def difficulty = column[String]("DIFFICULTY")
    override def * : ProvenShape[Challenge] = (id, created, link, title, body, difficulty) <> (
      (row: (String, Date, String, String, String, String)) =>
          Challenge(row._1, row._2, new URL(row._3), row._4, row._5, Difficulty(row._6)),
      (ch: Challenge) =>
          Some(ch.id, ch.created, ch.link.toString, ch.title, ch.body, ch.difficulty.difficulty))
  }
  val challenges = TableQuery[Challenges]

  class Responses(tag: Tag) extends Table[(String, String, String, Date, Option[String], String)](tag, "RESPONSES") {
    def id = column[String]("ID", O.PrimaryKey)
    def challengeID = column[String]("CHALLENGE_ID")
    def username = column[String]("USERNAME")
    def created = column[Date]("CREATED")
    def link = column[Option[String]]("LINK")
    def body = column[String]("BODY")
    def challenge = foreignKey("CHALLENGE_ID", challengeID, challenges)(_.id, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade)
    def user = foreignKey("USERNAME", username, users)(_.username, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade)
    override def * : (Rep[String], Rep[String], Rep[String], Rep[Date], Rep[Option[String]], Rep[String]) =
      (id, challengeID, username, created, link, body)
  }

  object responses extends TableQuery(new Responses(_)) {
    def insertRow(id: String, chId: String, uname: String, created: Date, link: Option[String], body: String) = {
      this += ((id, chId, uname, created, link, body))
    }
    val insertCompiled = Compiled(insertRow _)
//    def insertResponse(r: Response) = insertCompiled(r.id, r.challenge.id, r.user.username, r.created, r.link.map(_.toString), r.body)
  }
} 
开发者ID:Ophirr33,项目名称:daily-programmer-scraper,代码行数:52,代码来源:tables.scala


示例10: TaskEntity

//设置package包名称以及导入依赖的类
package com.github.mkorman9.districron.entity

import slick.driver.MySQLDriver.simple._
import slick.lifted.Tag

case class TaskEntity(name: String,
                      cronExpression: String,
                      globalDistribution: Boolean,
                      recipient: String,
                      executionInterval: Int)

class Tasks(tag: Tag) extends Table[TaskEntity](tag, "task") {
  def name = column[String]("name", O.PrimaryKey)
  def cronExpression = column[String]("cron_expression")
  def globalDistribution = column[Boolean]("global_distribution")
  def recipient = column[String]("recipient")
  def executionInterval = column[Int]("execution_interval")

  override def * = (name, cronExpression, globalDistribution, recipient, executionInterval) <>(TaskEntity.tupled, TaskEntity.unapply)
} 
开发者ID:mkorman9,项目名称:districron,代码行数:21,代码来源:TaskEntity.scala


示例11: TaskExecutionEntity

//设置package包名称以及导入依赖的类
package com.github.mkorman9.districron.entity

import java.sql.Timestamp

import slick.driver.MySQLDriver.simple._
import slick.lifted.Tag

case class TaskExecutionEntity(id: Long,
                               taskName: String,
                               runTimestamp: Timestamp,
                               success: Option[Boolean])

class TaskExecutions(tag: Tag) extends Table[TaskExecutionEntity](tag, "task") {
  def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
  def taskName = column[String]("task_name")
  def runTimestamp = column1653284372("run_timestamp")
  def success = column[Boolean]("success")

  def task = foreignKey("fk_task_execution_task", taskName, TableQuery[Tasks])(_.name)

  override def * = (id, taskName, runTimestamp, success.?) <>(TaskExecutionEntity.tupled, TaskExecutionEntity.unapply)
} 
开发者ID:mkorman9,项目名称:districron,代码行数:23,代码来源:TaskExecutionEntity.scala


示例12: Page

//设置package包名称以及导入依赖的类
package models

import java.util.Date
import java.sql.{ Date => SqlDate }
import play.api.Play.current
import slick.lifted.Tag
import java.sql.Timestamp
import slick.driver.PostgresDriver.api._

case class Page[A](items: Seq[A], page: Int, offset: Long, total: Long) {
  lazy val prev = Option(page - 1).filter(_ >= 0)
  lazy val next = Option(page + 1).filter(_ => (offset + items.size) < total)
}

case class Employee(id: Option[Long], name: String, address: String, dob: Option[Date], joiningDate: Date, designation: Option[String])

class Employees(tag: Tag) extends Table[Employee](tag, "EMPLOYEE") {

  implicit val dateColumnType = MappedColumnType.base[Date, Long](d => d.getTime, d => new Date(d))

  def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
  def name = column[String]("name")
  def address = column[String]("address")
  def dob = column[Date]("date_of_birth")
  def joiningDate = column[Date]("joining_date")
  def designation = column[String]("designation")

  def * = (id.?, name, address, dob.?, joiningDate, designation.?) <> (Employee.tupled, Employee.unapply _)

} 
开发者ID:Froom2,项目名称:scala-heroku-postgres-test2,代码行数:31,代码来源:domain.scala


示例13: Transfers

//设置package包名称以及导入依赖的类
package com.peim.model.table

import java.time.OffsetDateTime

import com.peim.model.{Transfer, TransferStatus}
import slick.driver.H2Driver.api._
import slick.lifted.Tag

class Transfers(tag: Tag) extends Table[Transfer](tag, "transfers") {

  import Transfer._

  def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
  def sourceAccountId = column[Int]("source_account_id")
  def destAccountId = column[Int]("dest_account_id")
  def currencyId = column[Int]("currency_id")
  def sum = column[Double]("sum")
  def created = column[OffsetDateTime]("created")
  def status = column[TransferStatus]("status")

  def * = (id, sourceAccountId, destAccountId, currencyId, sum, created, status) <> (Transfer.tupled, Transfer.unapply)
} 
开发者ID:peim,项目名称:money-transfer-service,代码行数:23,代码来源:Transfers.scala


示例14: TicketTable

//设置package包名称以及导入依赖的类
package io.github.asepsaep.laporcrawler.model

import io.github.asepsaep.laporcrawler.modules.{ DatabaseComponent, DriverComponent }
import io.github.asepsaep.laporcrawler.repository.Repository

trait TicketComponent { this: DatabaseComponent with DriverComponent ?

  import slick.lifted.Tag
  import driver.api._

  class TicketTable(tag: Tag) extends Table[Ticket](tag, "ticket") {
    def id = column[Int]("id")
    def title = column[String]("title")
    def content = column[String]("content")
    def user = column[String]("user")
    def date = column[String]("date")
    def platform = column[String]("platform")
    def category = column[String]("category")
    def area = column[String]("area")
    def status = column[String]("status")
    def dispatchedTo = column[String]("dispatched_to")

    override def * = (
      id,
      title,
      content,
      user.?,
      date.?,
      platform.?,
      category.?,
      area.?,
      status.?,
      dispatchedTo.?
    ) <> ((Ticket.apply _).tupled, Ticket.unapply _)
  }

  object TicketRepository extends Repository[TicketTable, Int](driver, db) {
    import this.driver.api._

    val table = TableQuery[TicketTable]
    def getId(table: TicketTable) = table.id
  }

} 
开发者ID:asepsaep,项目名称:lapor-crawler,代码行数:45,代码来源:TicketComponent.scala


示例15: Scenario

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

import slick.lifted.Tag
import slick.driver.SQLiteDriver.api._


case class Scenario(id: String, body: String)

class Scenarios(tag: Tag) extends Table[Scenario](tag,"scenarios") {
  def id = column[String]("id")
  def body = column[String]("body")
  def * = (id,body) <> (Scenario.tupled,Scenario.unapply)
}

object Scenarios {
  lazy val all = TableQuery[Scenarios]
  val findById = Compiled {id: Rep[String] => all.filter(_.id === id)}
  def add(id: String, body: String) = all += new Scenario(id,body)
  def delete(id: String) = all.filter(_.id === id).delete
} 
开发者ID:macgemini,项目名称:tytanis,代码行数:21,代码来源:Scenarios.scala


示例16: JobInfo

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

import slick.lifted.Tag
import slick.driver.SQLiteDriver.api._


case class JobInfo(id: String, name: String ,status: String, startTime: Long, endTime: Long,
                   scenario: String, scheduled: Int, completed: Int, cancelled: Int,
                   succeeded: Int, failed: Int)

object JobStatus extends Enumeration {
  type JobStatus = Value
  val PENDING, COMPLETED, KILLED = Value
}

class Jobs(tag: Tag) extends Table[JobInfo](tag,"jobs") {
  def id = column[String]("id")
  def name = column[String]("name")
  def status = column[String]("status")
  def startTime = column[Long]("startTime")
  def endTime = column[Long]("endTime")
  def scenario = column[String]("scenario")
  def scheduled = column[Int]("scheduled")
  def completed = column[Int]("completed")
  def cancelled = column[Int]("cancelled")
  def succeeded = column[Int]("succeeded")
  def failed = column[Int]("failed")

  def * = (id,name,status,startTime,endTime,scenario,scheduled,completed,cancelled,succeeded,failed) <> (JobInfo.tupled,JobInfo.unapply)
}

object Jobs {
  lazy val all = TableQuery[Jobs]
  val findById = Compiled {id: Rep[String] => all.filter(_.id === id)}
  def add(jobInfo: JobInfo) = all += jobInfo
  def delete(id: String) = all.filter(_.id === id).delete
} 
开发者ID:macgemini,项目名称:tytanis,代码行数:38,代码来源:Jobs.scala


示例17: Event

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

import slick.lifted.Tag
import slick.driver.SQLiteDriver.api._


case class Event(id: String, body: String)

class Events(tag: Tag) extends Table[Event](tag,"events") {
  def id = column[String]("id")
  def body = column[String]("body")
  def * = (id,body) <> (Event.tupled,Event.unapply)
}

object Events {
  lazy val all = TableQuery[Events]
  val findById = Compiled {id: Rep[String] => all.filter(_.id === id)}
  def add(id: String, body: String) = all += new Event(id,body)
  def delete(id: String) = all.filter(_.id === id).delete
} 
开发者ID:macgemini,项目名称:tytanis,代码行数:21,代码来源:Events.scala


示例18: Fruit

//设置package包名称以及导入依赖的类
package models

import javax.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import play.api.libs.json._
import slick.driver.JdbcProfile
import slick.driver.MySQLDriver.api._
import slick.lifted.{TableQuery, Tag}
import javax.inject.Singleton
import scala.concurrent.Future

case class Fruit (id:Int, name:String, value:Int)

object Fruit {

   implicit object FruitFormat extends Format[Fruit] {
      // convert from Fruit object to JSON (serializing to JSON)
      def writes(fruit: Fruit): JsValue = {
         val fruitSeq = Seq(
            "name" -> JsString(fruit.name),
            "value" -> JsNumber(fruit.value)
         )
         JsObject(fruitSeq)
      }
      // convert from JSON string to a Fruit object (de-serializing from JSON)
      def reads(json: JsValue): JsResult[Fruit] = {
         JsSuccess(Fruit((json \ "id").as[Int], (json \ "name").as[String], (json \ "value").as[Int]))
      }
   }

   def tupled = (this.apply _).tupled
}

@Singleton
class DBFruits @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) {
   val dbConfig = dbConfigProvider.get[JdbcProfile]

   val fruits = TableQuery[Fruits]

   def getTopFruits: Future[Seq[Fruit]] = {
      dbConfig.db.run(fruits.sortBy(_.value.desc).take(5).result)
   }

   class Fruits(tag: Tag) extends Table[Fruit](tag, "fruits") {
      def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
      def name = column[String]("name")
      def value = column[Int]("value")
      override def * = (id, name, value) <> (Fruit.tupled, Fruit.unapply)
   }
} 
开发者ID:anychart-integrations,项目名称:scala-play-mysql-template,代码行数:51,代码来源:DBFruits.scala


示例19: Schema

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

import kidstravel.shared.geo.{City, Country, Subdivision}
import kidstravel.shared.poi.Poi
import slick.driver.H2Driver.api._
import slick.lifted.Tag

object Schema {

  class Countries(tag: Tag) extends Table[Country](tag, "country") {
    def code = column[String]("code", O.PrimaryKey)
    def name = column[String]("name")
    def * = (code, name) <> (Country.tupled, Country.unapply)
  }

  val countries = TableQuery[Countries]

  class Subdivisions(tag: Tag) extends Table[Subdivision](tag, "subdivision") {
    def id = column[Long]("id", O.PrimaryKey)
    def name = column[String]("name")
    def countryCode = column[String]("country_code")
    def country = foreignKey("fk_country", countryCode, countries)(_.code, onUpdate = ForeignKeyAction.Restrict, onDelete = ForeignKeyAction.Restrict)
    def * = (id, name, countryCode) <> (Subdivision.tupled, Subdivision.unapply)
  }

  val subdivisions = TableQuery[Subdivisions]

  class Cities(tag: Tag) extends Table[City](tag, "city") {
    def id = column[Long]("id", O.PrimaryKey)
    def name = column[String]("name")
    def countryCode = column[String]("country_code")
    def country = foreignKey("fk_country", countryCode, countries)(_.code, onUpdate = ForeignKeyAction.Restrict, onDelete = ForeignKeyAction.Restrict)
    def subdivisionId = column[Option[Long]]("subdivision_id")
    def subdivision = foreignKey("fk_subdivision", subdivisionId, subdivisions)(_.id.?, onUpdate = ForeignKeyAction.Restrict, onDelete = ForeignKeyAction.Restrict)
    def population = column[Option[Long]]("population")
    def * = (id, name, countryCode, subdivisionId, population) <> (City.tupled, City.unapply)
  }

  val cities = TableQuery[Cities]

  class Pois(tag: Tag) extends Table[Poi](tag, "poi") {
    def id = column[Long]("id", O.PrimaryKey)
    def name = column[String]("name")
    def * = (id, name) <> (Poi.tupled, Poi.unapply)
  }

  val pois = TableQuery[Pois]


} 
开发者ID:devkat,项目名称:kidstravel,代码行数:51,代码来源:Schema.scala


示例20: DownInformations

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

import models._
import slick.lifted.{ForeignKeyQuery, Tag}
import slick.driver.H2Driver.api._

class DownInformations(tag: Tag) extends Table[DownInformation](tag, "down_informations") {
  def id: Rep[Int] = column[Int]("id", O.PrimaryKey, O.AutoInc)
  def name: Rep[String] = column[String]("name")
  def down: Rep[Int] = column[Int]("down")
  def yards: Rep[Int] = column[Int]("yards")
  def gained: Rep[Int] = column[Int]("gained")
  def playId: Rep[Int] = column[Int]("play_id")
  def targetId: Rep[Int] = column[Int]("target_id")
  def formationId: Rep[Int] = column[Int]("formation_id")
  def gameId: Rep[Int] = column[Int]("game_id")
  def * = (id.?, name, down, yards, gained, formationId, playId, targetId, gameId) <> ((DownInformation.apply _).tupled, DownInformation.unapply)
  def formationFk: ForeignKeyQuery[Formations, Formation] = foreignKey("formation", formationId, Formations.objects)(_.id, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade)
  def playFk: ForeignKeyQuery[PlayInformations, PlayInformation] = foreignKey("play", playId, PlayInformations.objects)(_.id, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade)
  def targetFk: ForeignKeyQuery[Players, Player] = foreignKey("target", targetId, Players.objects)(_.id, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade)
  def gameFk: ForeignKeyQuery[Games, Game] = foreignKey("game", gameId, Games.objects)(_.id, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade)
}
//   def supplier = foreignKey("SUP_FK", supID, suppliers)(_.id, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade)
object DownInformations {
  val objects: TableQuery[DownInformations] = TableQuery[DownInformations]
} 
开发者ID:vililahtevanoja,项目名称:Predator-App-Server,代码行数:27,代码来源:DownInformations.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Matrix类代码示例发布时间:2022-05-23
下一篇:
Scala Tcp类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap