rethinkdb_dart 2.3.2+5

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 46

Build Status

Dart 2 and Flutter RethinkDB Driver #

A Dart 2 and Flutter driver for RethinkDB v2.3.

This is a fork of RethinkDB Driver, that was created to update the driver to Dart 2 and Flutter.

Getting Started: #

The driver api tries to align with the javascript and python RethinkDB drivers. You can read their documentation here.

To include this driver in your own project add the package to your pubspec.yaml file:

dependencies:
  rethinkdb_dart: '^2.3.2+5'

Or to use bleeding edge:

dependencies:
  rethinkdb_dart:
    git: git://github.com/marceloneppel/rethinkdb.git

Or if you are a developer:

  dependencies:
    rethinkdb_dart:
      path: /path/to/your/cloned/rethinkdb_dart

Then import the package into your project:

import 'package:rethinkdb_dart/rethinkdb_dart.dart';

Connect to the database:

var connection = await r.connect(db: "test", host: "localhost", port: 28015);

Create a table:

await r.db('test').tableCreate('tv_shows').run(connection);

Insert some data:

await r.table('tv_shows').insert([
      {'name': 'Star Trek TNG', 'episodes': 178},
      {'name': 'Battlestar Galactica', 'episodes': 75}
    ]).run(connection);

And work with the data:

var count = await r.table('tv_shows').count();
print("count: $count");

To run tests execute the following command from the project root:

warning: tests are run against a live database, but they do attempt to clean up after themselves

pub run test  

2.3.2+5 #

  • Made 'SocketException: OS Error: Connection refused' handleable by user code

2.3.2+4 #

  • Fixed connection close listener
  • Fixed connection test according to JavaScript driver

2.3.2+3 #

  • Initial release (driver updated to Dart 2 and Flutter)

example/example.dart

import 'package:rethinkdb_dart/rethinkdb_dart.dart';

Rethinkdb r = new Rethinkdb();

void main(List<String> arguments) async {
  var connection;
  try {
    // Create the database connection.
    connection = await r.connect(db: "test", host: "localhost", port: 28015);

    // Drop the table if it exists.
    await r
        .db('test')
        .tableList()
        .contains('tv_shows')
        .not()
        .rqlDo((databaseExists) {
      return r.branch(
          databaseExists, r.tableList(), r.db('test').tableDrop('tv_shows'));
    }).run(connection);

    // Create the table if it doesn't exist.
    await r.db('test').tableList().contains('tv_shows').rqlDo((databaseExists) {
      return r.branch(
          databaseExists, r.tableList(), r.db('test').tableCreate('tv_shows'));
    }).run(connection);

    // Insert some data.
    await r.table('tv_shows').insert([
      {'name': 'Star Trek TNG', 'episodes': 178},
      {'name': 'Battlestar Galactica', 'episodes': 75}
    ]).run(connection);

    // Display the data count.
    var count = await r.table('tv_shows').count().run(connection);
    print("count: $count");
  } catch (e) {
    print("Error: $e");
  } finally {
    if (connection != null) {
      connection.close();
    }
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  rethinkdb_dart: ^2.3.2+5

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:rethinkdb_dart/rethinkdb_dart.dart';
  
Version Uploaded Documentation Archive
2.3.2+5 Jan 25, 2019 Go to the documentation of rethinkdb_dart 2.3.2+5 Download rethinkdb_dart 2.3.2+5 archive
2.3.2+4 Jan 24, 2019 Go to the documentation of rethinkdb_dart 2.3.2+4 Download rethinkdb_dart 2.3.2+4 archive
2.3.2+3 Dec 30, 2018 Go to the documentation of rethinkdb_dart 2.3.2+3 Download rethinkdb_dart 2.3.2+3 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
57
Health:
Code health derived from static analysis. [more]
59
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18

Platforms

Detected platforms: Flutter, other

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

Health suggestions

Fix lib/rethinkdb_dart.dart. (-29.24 points)

Analysis of lib/rethinkdb_dart.dart reported 69 hints, including:

line 44 col 1: Prefer using /// for doc comments.

line 71 col 1: Prefer using /// for doc comments.

line 216 col 1: Prefer using /// for doc comments.

line 256 col 1: Prefer using /// for doc comments.

line 325 col 1: Prefer using /// for doc comments.

Fix lib/src/net.dart. (-12.66 points)

Analysis of lib/src/net.dart reported 27 hints, including:

line 11 col 9: Don't type annotate initializing formals.

line 11 col 39: Don't type annotate initializing formals.

line 12 col 8: Don't type annotate initializing formals.

line 12 col 29: Don't type annotate initializing formals.

line 40 col 12: Don't type annotate initializing formals.

Fix lib/src/ast.dart. (-3.45 points)

Analysis of lib/src/ast.dart reported 7 hints, including:

line 281 col 7: DO use curly braces for all flow control structures.

line 315 col 9: Use isNotEmpty instead of length

line 391 col 11: Use contains instead of indexOf

line 429 col 11: DO use curly braces for all flow control structures.

line 437 col 11: DO use curly braces for all flow control structures.

Fix additional 5 files with analysis or formatting issues. (-1.49 points)

Additional issues in the following files:

  • lib/src/cursor.dart (3 hints)
  • lib/src/generated/ql2.pb.dart (Run dartfmt to format lib/src/generated/ql2.pb.dart.)
  • lib/src/generated/ql2.pbenum.dart (Run dartfmt to format lib/src/generated/ql2.pbenum.dart.)
  • lib/src/generated/ql2.pbjson.dart (Run dartfmt to format lib/src/generated/ql2.pbjson.dart.)
  • lib/src/generated/ql2.pbserver.dart (Run dartfmt to format lib/src/generated/ql2.pbserver.dart.)

Maintenance issues and suggestions

Prefer published dependencies. (-100 points)

The source code in a git repository is mutable and could disappear.

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: pbkdf2.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (1 direct: protobuf).

The package description is too short. (-20 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.20.0 <3.0.0
convert ^2.0.2 2.1.1
crypto ^2.0.6 2.0.6
pbkdf2 2.1.0
protobuf ^0.10.2 0.10.8 0.13.12
Transitive dependencies
charcode 1.1.2
collection 1.14.11
fixnum 0.10.9
typed_data 1.1.6
Dev dependencies
test ^1.3.0