Last active
September 1, 2017 19:37
-
-
Save adriencanterot/fc5fb983e55cab115440406e33c3e88f to your computer and use it in GitHub Desktop.
create a simple sqlite database for Fluent
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
func configureDatabase() { | |
let manager = FileManager.default | |
let applicationDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) | |
let databasePath = applicationDirectory.first! + "/development.sqlite" | |
if !manager.fileExists(atPath: databasePath) { | |
manager.createFile(atPath: databasePath, contents: nil, attributes: nil) | |
} | |
let driver = try! SQLiteDriver(path: databasePath) | |
self.database = Fluent.Database(driver) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment