Encodable

public protocol Encodable: Expr

Encodable protocol is used to specify how a Swift data structure is converted to a valid FaunaDB value when sending data to the server.

For example:

struct Point { let x, y: Int }

extension Point: Encodable {
    func encode() -> Expr {
        return Obj(
            "x" => x,
            "y" => y
        )
    }
}

//...

client.query(
    Create(
        at: Class("points"),
        Obj("data" => Point(x: 10, y: 15))
    )
)
  • Undocumented

    Declaration

    Swift

    public protocol Encodable: Expr