Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Last active May 30, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphicbeacon/952270533aace31b5362166b5cd7c7e7 to your computer and use it in GitHub Desktop.
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)
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