angel_rethink 1.0.7

  • README.md
  • Installing
  • Versions
  • 41

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. Depend on it

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


dependencies:
  angel_rethink: "^1.0.7"

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.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

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 14, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
29 / 100
Health:
Code health derived from static analysis. [more]
40 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
76 / 100
Overall score:
Weighted score of the above. [more]
41

Platforms

Detected platforms: other

Primary library: package:angel_rethink/angel_rethink.dart with components: io, mirrors.

Suggestions

  • Fix lib/src/rethink_service.dart.

    Strong-mode analysis of lib/src/rethink_service.dart failed with the following error:

    line: 133 col: 60
    The getter 'CREATED' isn't defined for the class 'HookedServiceEvent'.

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).

  • The description is too short.

    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.

    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
angel_framework ^1.0.0-dev 1.1.1
rethinkdb_driver2 ^2.3.1 2.3.1
Transitive dependencies
angel_http_exception 1.0.0
angel_model 1.0.0
angel_route 2.0.5
async 2.0.3 2.0.4
body_parser 1.0.3
charcode 1.1.1
collection 1.14.5
combinator 1.0.0-beta+7
container 0.1.2
convert 2.0.1
crypto 2.0.2+1
fixnum 0.10.7
http_server 0.9.7
json_god 2.0.0-beta+1
logging 0.11.3+1
matcher 0.12.1+4
merge_map 1.0.0
meta 1.1.2
mime 0.9.6
path 1.5.1
pool 1.3.4
protobuf 0.5.5 0.7.0
quiver_hashcode 1.0.0
random_string 0.0.1
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
tuple 1.0.1
typed_data 1.1.5
Dev dependencies
angel_test ^1.0.0-dev
test ^0.12.0