angel_rethink 1.1.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 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<T>

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';
  
Version Uploaded Documentation Archive
1.1.0 Jun 4, 2018 Go to the documentation of angel_rethink 1.1.0 Download angel_rethink 1.1.0 archive
1.0.7 Apr 10, 2017 Go to the documentation of angel_rethink 1.0.7 Download angel_rethink 1.0.7 archive
1.0.6 Mar 7, 2017 Go to the documentation of angel_rethink 1.0.6 Download angel_rethink 1.0.6 archive
1.0.5 Mar 7, 2017 Go to the documentation of angel_rethink 1.0.5 Download angel_rethink 1.0.5 archive
1.0.4 Mar 4, 2017 Go to the documentation of angel_rethink 1.0.4 Download angel_rethink 1.0.4 archive
1.0.3 Mar 2, 2017 Go to the documentation of angel_rethink 1.0.3 Download angel_rethink 1.0.3 archive
1.0.2 Feb 23, 2017 Go to the documentation of angel_rethink 1.0.2 Download angel_rethink 1.0.2 archive
1.0.1 Feb 22, 2017 Go to the documentation of angel_rethink 1.0.1 Download angel_rethink 1.0.1 archive
1.0.0 Feb 22, 2017 Go to the documentation of angel_rethink 1.0.0 Download angel_rethink 1.0.0 archive
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.1.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.

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use angel_rethink.dart.

Dependencies

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