-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple in-memory databases (#86)
* cleanup config storage * fix comments
- Loading branch information
1 parent
d6f72bb
commit 442968e
Showing
3 changed files
with
62 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import struct Foundation.UUID | ||
|
||
public struct SQLiteConfiguration { | ||
public enum Storage { | ||
/// Stores the SQLite database in memory. | ||
/// | ||
/// Uses a randomly generated identifier. See `memory(identifier:)`. | ||
public static var memory: Self { | ||
.memory(identifier: UUID().uuidString) | ||
} | ||
|
||
/// Stores the SQLite database in memory. | ||
/// - parameters: | ||
/// - identifier: Uniquely identifies the in-memory storage. | ||
/// Connections using the same identifier share data. | ||
case memory(identifier: String) | ||
|
||
/// Uses the SQLite database file at the specified path. | ||
/// | ||
/// Non-absolute paths will check the current working directory. | ||
case file(path: String) | ||
} | ||
|
||
public var storage: Storage | ||
|
||
/// If `true`, foreign keys will be enabled automatically on new connections. | ||
public var enableForeignKeys: Bool | ||
|
||
/// Creates a new `SQLiteConfiguration`. | ||
public init(storage: Storage, enableForeignKeys: Bool = true) { | ||
self.storage = storage | ||
self.enableForeignKeys = enableForeignKeys | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters