Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Last active May 22, 2018 21:01
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/a16f8484103489b7cb07b7768ea3039b to your computer and use it in GitHub Desktop.
Save graphicbeacon/a16f8484103489b7cb07b7768ea3039b to your computer and use it in GitHub Desktop.
Sample code for "Building RESTful Web APIs with Dart, Aqueduct and PostgreSQL (Part 3)" post on Medium (2)
class FaveReadsSink extends RequestSink {
FaveReadsSink(ApplicationConfiguration appConfig) : super(appConfig) {
logger.onRecord.listen(
(rec) => print("$rec ${rec.error ?? ""} ${rec.stackTrace ?? ""}"));
var managedDataModel = new ManagedDataModel.fromCurrentMirrorSystem(); // load our models
var persistentStore = new PostgreSQLPersistentStore.fromConnectionInfo(
"dartuser", "dbpass123", "localhost", 5432, "fave_reads"); // configure the db connection
ManagedContext.defaultContext = new ManagedContext(managedDataModel, persistentStore);
}
// ...
// ...remaining logic
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment