mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Documentation WIP
This commit is contained in:
1 parent
beea0299fa
commit
5334dcd769
1 file changed
+25
-2
@@ -27,6 +27,8 @@ Configuration are arguments to the DatabaseQueue initializers.
|
||||
*/
|
||||
public struct Configuration {
|
||||
|
||||
// MARK: - Utilities
|
||||
|
||||
/// A tracing function that logs SQL statements
|
||||
public static func logSQL(sql: String, bindings: Bindings?) {
|
||||
NSLog("GRDB: %@", sql)
|
||||
@@ -35,7 +37,14 @@ public struct Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
/// A tracing function.
|
||||
// MARK: - Configuration options
|
||||
|
||||
/**
|
||||
A tracing function.
|
||||
|
||||
- parameter sql: An SQL query
|
||||
- parameter bindings: Eventual bindings that hold SQL parameters.
|
||||
*/
|
||||
public typealias TraceFunction = (sql: String, bindings: Bindings?) -> Void
|
||||
|
||||
/// If true, the database has support for foreign keys.
|
||||
@@ -44,12 +53,23 @@ public struct Configuration {
|
||||
/// If true, the database is opened readonly.
|
||||
public var readonly: Bool
|
||||
|
||||
/// A tracing function that you can use for any purpose.
|
||||
/**
|
||||
An optional tracing function.
|
||||
|
||||
You can use Configuration.logSQL as a tracing function: it logs all SQL
|
||||
statements with NSLog().
|
||||
*/
|
||||
public var trace: TraceFunction?
|
||||
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
/**
|
||||
Setup a configuration.
|
||||
|
||||
You can use Configuration.logSQL as a tracing function: it logs all SQL
|
||||
statements with NSLog().
|
||||
|
||||
- parameter foreignKeysEnabled: If true (the default), the database has
|
||||
support for foreign keys.
|
||||
- parameter readonly: If false (the default), the database will be
|
||||
@@ -65,6 +85,9 @@ public struct Configuration {
|
||||
self.trace = trace
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Not public
|
||||
|
||||
var sqliteOpenFlags: Int32 {
|
||||
// See https://www.sqlite.org/c3ref/open.html
|
||||
return readonly ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
|
||||
|
||||
Reference in new issue
Block a user