Last active
May 30, 2018 18:13
-
-
Save graphicbeacon/952270533aace31b5362166b5cd7c7e7 to your computer and use it in GitHub Desktop.
Sample code for "Building RESTful Web APIs with Dart, Aqueduct and PostgreSQL (Part 4)" post on Medium (2)
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
class FaveReadsSink extends RequestSink { | |
FaveReadsConfiguration config; | |
FaveReadsSink(ApplicationConfiguration appConfig) : super(appConfig) { | |
logger.onRecord.listen( | |
(rec) => print("$rec ${rec.error ?? ""} ${rec.stackTrace ?? ""}")); | |
var configFilePath = appConfig.configurationFilePath; | |
config = new FaveReadsConfiguration(configFilePath); | |
var managedDataModel = new ManagedDataModel.fromCurrentMirrorSystem(); | |
var persistentStore = new PostgreSQLPersistentStore.fromConnectionInfo( | |
config.database.username, | |
config.database.password, | |
config.database.host, | |
config.database.port, | |
config.database.databaseName); | |
ManagedContext.defaultContext = new ManagedContext(managedDataModel, persistentStore); | |
} | |
// ... | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment