angel_rethink 1.1.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 64

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

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:angel_rethink/angel_rethink.dart.

Suggestions

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

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run dartfmt to format lib/angel_rethink.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
angel_framework ^1.1.0 1.1.4+3
json_god ^2.0.0-beta 2.0.0-beta+1
rethinkdb_driver ^2.3.1 2.3.2+2
Transitive dependencies
angel_http_exception 1.0.0
angel_model 1.0.0
angel_route 2.0.6
async 2.0.7
body_parser 1.1.0
charcode 1.1.1
code_buffer 1.0.0
collection 1.14.10
combinator 1.0.0
container 0.1.2
convert 2.0.1
crypto 2.0.5
dart2_constant 1.0.1+dart2
fixnum 0.10.7
http_parser 3.1.2
http_server 0.9.7
matcher 0.12.3
merge_map 1.0.0
meta 1.1.5
mime 0.9.6+1
path 1.6.1
pbkdf2 0.2.0
pool 1.3.5
protobuf 0.7.2 0.9.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_client ^1.1.0
angel_test ^1.1.0
logging ^0.11.3 0.11.3+1
test ^0.12.0