angel_orm_service 1.0.0

angel_orm_service #

Pub build status

Service implementation that wraps over Angel ORM Query classes.

Installation #

In your pubspec.yaml:

dependencies:
    angel_orm_service: ^1.0.0

Usage #

Brief snippet (check example/main.dart for setup, etc.):

// Create an ORM-backed service.
  var todoService = OrmService<int, Todo, TodoQuery>(
      executor, () => TodoQuery(),
      readData: (req, res) => todoSerializer.decode(req.bodyAsMap));

  // Because we provided `readData`, the todoService can face the Web.
  // **IMPORTANT: Providing the type arguments is an ABSOLUTE MUST, if your
  // model has `int` ID's (this is the case when using `angel_orm_generator` and `Model`).
  // **
  app.use<int, Todo, OrmService<int, Todo, TodoQuery>>(
      '/api/todos', todoService);

1.0.0 #

  • First version.

example/main.dart

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_orm_service/angel_orm_service.dart';
import 'package:logging/logging.dart';
import 'connect.dart';
import 'todo.dart';

main() async {
  // Logging, connection setup.
  hierarchicalLoggingEnabled = true;
  var app = Angel(logger: Logger.detached('orm_service'));
  var http = AngelHttp(app);
  var executor = await connect();
  app.logger.onRecord.listen((rec) {
    print(rec);
    if (rec.error != null) print(rec.error);
    if (rec.stackTrace != null) print(rec.stackTrace);
  });

  // Create an ORM-backed service.
  var todoService = OrmService<int, Todo, TodoQuery>(
      executor, () => TodoQuery(),
      readData: (req, res) => todoSerializer.decode(req.bodyAsMap));

  // Because we provided `readData`, the todoService can face the Web.
  // **IMPORTANT: Providing the type arguments is an ABSOLUTE MUST, if your
  // model has `int` ID's (this is the case when using `angel_orm_generator` and `Model`).
  // **
  app.use<int, Todo, OrmService<int, Todo, TodoQuery>>(
      '/api/todos', todoService);

  // Clean up when we are done.
  app.shutdownHooks.add((_) => executor.close());

  await http.startServer('127.0.0.1', 3000);
  print('Listening at ${http.uri}');
  print('Todos API: ${http.uri}/api/todos');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angel_orm_service: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:angel_orm_service/angel_orm_service.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
12
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

We analyzed this package on Aug 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:angel_orm_service/angel_orm_service.dart with components: io.

Health suggestions

Fix lib/angel_orm_service.dart. (-0.50 points)

Analysis of lib/angel_orm_service.dart reported 1 hint:

line 71 col 19: DO use curly braces for all flow control structures.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
angel_framework ^2.0.0-alpha 2.0.4+1
angel_orm ^2.0.0 2.0.2
Transitive dependencies
angel_container 1.0.4
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.0.6
charcode 1.1.2
code_buffer 1.0.1
collection 1.14.12
combinator 1.1.0
convert 2.1.1
crypto 2.1.2
dart2_constant 1.0.2+dart2
file 5.0.8+1
http2 1.0.0
http_parser 3.1.3
http_server 0.9.8+3
intl 0.15.8
matcher 0.12.5
merge_map 1.0.2
meta 1.1.7
mime 0.9.6+3
mock_request 1.0.6
path 1.6.4
quiver 2.0.5
quiver_hashcode 2.0.0
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.2
typed_data 1.1.6
uuid 2.0.2
Dev dependencies
angel_migration ^2.0.0-alpha
angel_migration_runner
angel_orm_generator
angel_orm_postgres
angel_orm_test
angel_serialize ^2.0.0
build_runner ^1.0.0
logging ^0.11.0 0.11.3+2
pedantic ^1.0.0 1.8.0+1
postgres ^1.0.0
test ^1.0.0