angel_rethink 1.1.0

rethink #

version 1.0.7 build status

RethinkDB-enabled services for the Angel framework.

Installation #

Add the following to your pubspec.yaml:

dependencies:
  angel_rethink: ^1.0.0

package:rethinkdb_driver2 will be installed as well.

Usage #

This library exposes one class: RethinkService. By default, these services will even listen to changefeeds from the database, which makes them very suitable for WebSocket use.

However, only CREATED, UPDATED and REMOVED events will be fired. This is technically not a problem, as it lowers the numbers of events you have to handle on the client side. ;)

Model #

Model is class with no real functionality; however, it represents a basic document, and your services should host inherited classes. Other Angel service providers host Model as well, so you will easily be able to modify your application if you ever switch databases.

class User extends Model {
  String username;
  String password;
}

main() async {
    var r = new RethinkDb();
    var conn = await r.connect();

    app.use('/api/users', new RethinkService(conn, r.table('users')));
    
    // Add type de/serialization if you want
    app.use('/api/users', new TypedService<User>(new RethinkService(conn, r.table('users'))));

    // You don't have to even use a table...
    app.use('/api/pro_users', new RethinkService(conn, r.table('users').filter({'membership': 'pro'})));
    
    app.service('api/users').afterCreated.listen((event) {
        print("New user: ${event.result}");
    });
}

RethinkService #

This class interacts with a Query (usually a table) and serializes data to and from Maps.

RethinkTypedService

Does the same as above, but serializes to and from a target class using package:json_god and its support for reflection.

Querying #

You can query these services as follows:

/path/to/service?foo=bar

The above will query the database to find records where 'foo' equals 'bar'.

The former will sort result in ascending order of creation, and so will the latter.

You can use advanced queries:

// Pass an actual query...
service.index({'query': r.table('foo').filter(...)});

// Or, a function that creates a query from a table...
service.index({'query': (table) => table.getAll('foo')});

// Or, a Map, which will be transformed into a `filter` query:
service.index({'query': {'foo': 'bar', 'baz': 'quux'}});

You can also apply sorting by adding a reql parameter on the server-side.

service.index({'reql': (query) => query.sort(...)});

See the tests for more usage examples.

1.1.0 #

  • Moved to package:rethinkdb_driver
  • Fixed references to old hooked event names.

Use this package as a library

1. Depend on it

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


dependencies:
  angel_rethink: ^1.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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_rethink/angel_rethink.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.4.0.
 
 Because angel_rethink depends on rethinkdb_driver >=0.3.0 which requires SDK version <2.0.0, version solving failed.

Health suggestions

Format lib/angel_rethink.dart.

Run dartfmt to format lib/angel_rethink.dart.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Package is getting outdated. (-12.05 points)

The package was last published 58 weeks ago.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and angel_rethink.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-9 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0

Admin