Skip to content

DatabaseField

Josh Wright edited this page Jan 14, 2021 · 3 revisions

DatabaseField

Represents a column & value pair in a database row.

public struct DatabaseField: Equatable

If there were a table with columns "id", "email", "phone" and a row with values 1 ,"josh@alchemy.dev", "(555) 555-5555", DatabaseField(column: id, .int(1)) would represent a field on that table.

Inheritance

Equatable

Properties

column

The name of the column this value came from.

let column: String

value

The value of this field.

let value: DatabaseValue

Methods

int()

Unwrap and return an Int value from this DatabaseField. This throws if the underlying value isn't an .int or the .int has a nil associated value.

public func int() throws -> Int

Throws

A DatabaseError if this field's value isn't a DatabaseValue.int or its contents is nil.

Returns

The unwrapped Int of this field's value, if it was indeed a non-null .int.

string()

Unwrap and return a String value from this DatabaseField. This throws if the underlying value isn't a .string or the .string has a nil associated value.

public func string() throws -> String

Throws

A DatabaseError if this field's value isn't a DatabaseValue.string or its contents is nil.

Returns

The unwrapped String of this field's value, if it was indeed a non-null .string.

double()

Unwrap and return a Double value from this DatabaseField. This throws if the underlying value isn't a .double or the .double has a nil associated value.

public func double() throws -> Double

Throws

A DatabaseError if this field's value isn't a DatabaseValue.double or its contents is nil.

Returns

The unwrapped Double of this field's value, if it was indeed a non-null .double.

bool()

Unwrap and return a Bool value from this DatabaseField. This throws if the underlying value isn't a .bool or the .bool has a nil associated value.

public func bool() throws -> Bool

Throws

A DatabaseError if this field's value isn't a DatabaseValue.bool or its contents is nil.

Returns

The unwrapped Bool of this field's value, if it was indeed a non-null .bool.

date()

Unwrap and return a Date value from this DatabaseField. This throws if the underlying value isn't a .date or the .date has a nil associated value.

public func date() throws -> Date

Throws

A DatabaseError if this field's value isn't a DatabaseValue.date or its contents is nil.

Returns

The unwrapped Date of this field's value, if it was indeed a non-null .date.

json()

Unwrap and return a JSON Data value from this DatabaseField. This throws if the underlying value isn't a .json or the .json has a nil associated value.

public func json() throws -> Data

Throws

A DatabaseError if this field's value isn't a DatabaseValue.json or its contents is nil.

Returns

The Data of this field's unwrapped json value, if it was indeed a non-null .json.

uuid()

Unwrap and return a UUID value from this DatabaseField. This throws if the underlying value isn't a .uuid or the .uuid has a nil associated value.

public func uuid() throws -> UUID

Throws

A DatabaseError if this field's value isn't a DatabaseValue.uuid or its contents is nil.

Returns

The unwrapped UUID of this field's value, if it was indeed a non-null .uuid.

Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally