-
Notifications
You must be signed in to change notification settings - Fork 35
PostgreSQL: Establish connection
Ravi Teja Gudapati edited this page Dec 27, 2017
·
1 revision
-
postgresql
: PostgreSQL client for Dart
connect
global method in postgresql
package is used to establish connection to PostgreSQL database. close
method on Connection
object shall be used to release the connection.
const String postgreUrl = "postgres://postgres:dart_jaguar@localhost/todos";
@Api(path: '/api/todos')
class TodoApi {
@Get(path: '/:id')
Future<Response<String>> getById(Context ctx) async {
String id = ctx.pathParams.id;
final pg.Connection db = pg.connect(postgreUrl);
...
db.close();
...
}
}
-
postgresql
: PostgreSQL client for Dart. -
jaguar_postgresql
: PostgreSQL interceptor for Jaguar.
jaguar_postgresql
package provides PostgresDb
interceptor to establish connection to PostgreSQL database before the execution of route handler and release the connection after the execution of route handler. PostgresDb
interceptor accepts URL of the PostgreSQL database as argument.
const String postgreUrl = "postgres://postgres:dart_jaguar@localhost/todos";
@Api(path: '/api/todos')
@Wrap(const [#postgres])
class TodoApi {
PostgresDb postgres(Context ctx) => new PostgresDb(postgreUrl);
@Post()
Future<Response<String>> insert(Context ctx) async {
final pg.Connection db = ctx.getInput<pg.Connection>(PostgresDb);
...
}
}
Basics
- Route handler
- Path matching
- Path parameters
- Query parameters
- Serving static files
- Cookies
- Controller
- Parameter binding
- Hot reload
Serialization
Forms
Sessions
Authentication
- Basic authentication
- Form authentication
- JSON authentication
- Authorization
- OAuth
- MongoDb
- PostgreSQL
- MySQL
- Establish connection
- ORM
- Server sent events (SSE)
- Websockets
- systemd
- Docker
- AppEngine