anorm.postgresql
package anorm.postgresql
Members list
Type members
Inherited classlikes
object JsObjectParameterMetaData extends ParameterMetaData[JsObject]
Attributes
- Inherited from:
- PGJson
- Supertypes
object JsValueParameterMetaData extends ParameterMetaData[JsValue]
Attributes
- Inherited from:
- PGJson
- Supertypes
Value members
Inherited methods
Sets a value as a JSON parameter.
Sets a value as a JSON parameter.
Type parameters
- the
-
type of value to be written as JSON
Value parameters
- value
-
the value to be passed as a JSON parameter
- w
-
the Play writes to be used to serialized the value as JSON
import play.api.libs.json._ import anorm._, postgresql._ case class Foo(bar: String) implicit val w: Writes[Foo] = Json.writes[Foo] implicit def con: java.sql.Connection = ??? val value = asJson(Foo("lorem")) SQL("INSERT INTO test(id, json) VALUES({id}, {json})"). on("id" -> "bar", "json" -> value).executeUpdate()
Attributes
- Inherited from:
- PGJson
Sets an optional value as a JSON parameters.
Sets an optional value as a JSON parameters.
Type parameters
- the
-
type of value to be written as JSON
Value parameters
- value
-
the optional value to be passed as a JSON parameter
- w
-
the Play writes to be used to serialized the value as JSON
import play.api.libs.json._ import anorm._, postgresql._ case class Foo(bar: String) implicit val w: Writes[Foo] = Json.writes[Foo] val someVal = asNullableJson(Some(Foo("lorem"))) val noVal = asNullableJson(Option.empty[Foo]) implicit def con: java.sql.Connection = ??? SQL("INSERT INTO test(id, json) VALUES({id}, {json})"). on("id" -> "bar", "json" -> someVal).executeUpdate() SQL("INSERT INTO test(id, json) VALUES({id}, {json})"). on("id" -> "bar", "json" -> noVal).executeUpdate()
Attributes
- Inherited from:
- PGJson
Value parameters
- r
-
the Play reader to be used from the selected JSONB value
import play.api.libs.json.Reads import anorm._, postgresql._ case class Foo(bar: String) def foo(implicit con: java.sql.Connection, r: Reads[Foo]): Foo = SQL"SELECT json FROM test". as(SqlParser.scalar(fromJson[Foo]).single)
Attributes
- Inherited from:
- PGJson
Implicits
Inherited implicits
import play.api.libs.json.JsObject
import anorm._, postgresql._
def foo(implicit con: java.sql.Connection) =
SQL"SELECT json FROM test".as(SqlParser.scalar[JsObject].single)
Attributes
- Inherited from:
- PGJson
import play.api.libs.json.JsValue
import anorm._, postgresql._
def foo(implicit con: java.sql.Connection) =
SQL"SELECT json FROM test".as(SqlParser.scalar[JsValue].single)
Attributes
- Inherited from:
- PGJson
Allows to pass a JsValue
as parameter to be stored as PGobject
.
In this article