Skip to content

Instantly share code, notes, and snippets.

@adriencanterot
Last active September 1, 2017 19:37
Show Gist options
  • Save adriencanterot/fc5fb983e55cab115440406e33c3e88f to your computer and use it in GitHub Desktop.
Save adriencanterot/fc5fb983e55cab115440406e33c3e88f to your computer and use it in GitHub Desktop.
create a simple sqlite database for Fluent
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