Extensions

The following extensions are available globally.

  • Swift’s Optional comes with built-in methods that allow to fetch cursors and arrays of optional DatabaseValueConvertible:

    try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String?
    try Optional<String>.fetchAll(db, sql: "SELECT name FROM ...", arguments:...)    // [String?]
    
    let statement = try db.makeSelectStatement(sql: "SELECT name FROM ...")
    try Optional<String>.fetchCursor(statement, arguments:...) // Cursor of String?
    try Optional<String>.fetchAll(statement, arguments:...)    // [String?]
    

    DatabaseValueConvertible is adopted by Bool, Int, String, etc.

    See more

    Declaration

    Swift

    extension Optional where Wrapped: DatabaseValueConvertible