All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.finagle.mysql.PreparedStatement.scala Maven / Gradle / Ivy

There is a newer version: 21.2.0
Show newest version
package com.twitter.finagle.mysql

import com.twitter.util.Future

/**
 * A PreparedStatement represents a parameterized
 * sql statement which may be applied concurrently
 * with varying parameters.
 */
trait PreparedStatement {
  /**
   * Executes the prepared statement with the
   * given `params`.
   */
  def apply(params: Parameter*): Future[Result]

  /**
   * Executes the prepared statement with the
   * given `params` and maps `f` to the rows
   * of the returned ResultSet. If no ResultSet
   * is returned, the function returns an empty Seq.
   */
  def select[T](params: Parameter*)(f: Row => T): Future[Seq[T]] =
    apply(params: _*) map {
      case rs: ResultSet => rs.rows.map(f)
      case _ => Nil
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy