From 3411e16418e93fb452c5a9a64813f877edb55928 Mon Sep 17 00:00:00 2001 From: Thomas Hii Date: Sat, 6 Jul 2024 18:15:18 +0800 Subject: [PATCH] Aded rethinkdb support --- packages/mongo/README.md | 8 ++++--- packages/mongo/pubspec.yaml | 2 +- packages/rethinkdb/README.md | 38 ++++++++++++++++----------------- packages/rethinkdb/pubspec.yaml | 7 +----- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/packages/mongo/README.md b/packages/mongo/README.md index e7f90ffe..8d86d771 100644 --- a/packages/mongo/README.md +++ b/packages/mongo/README.md @@ -66,14 +66,14 @@ See the tests for more usage examples. ## **Important Notes** -When connecting to the locally installed instance of MongoDB or docker based MongoDB with authentication enabled, the following connection string is not supported by the MongoDB driver yet. +When connecting to a locally installed instance of MongoDB or docker based MongoDB with authentication enabled, the following connection string is not supported yet. ```dart - var db = Db('mongodb://:@localhost:27017/local'); + var db = Db('mongodb://:@localhost:27017/testDB'); await db.open(); ``` -Use the following instead. +Use the following instead. By default the user access information is stored in `admin` database. ```dart var db = Db('mongodb://localhost:27017/testDB'); @@ -81,5 +81,7 @@ Use the following instead. await db.authenticate("", "", authDb: "admin"); ``` +Where + * `` is MongoDB username * `` is MongoDB password diff --git a/packages/mongo/pubspec.yaml b/packages/mongo/pubspec.yaml index ec745b34..41d16024 100644 --- a/packages/mongo/pubspec.yaml +++ b/packages/mongo/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_mongo version: 8.2.0 -description: MongoDB-enabled services for the Angel3 framework. Well-tested. +description: This is MongoDB-enabled service for the Angel3 framework. homepage: https://angel3-framework.web.app/ repository: https://github.com/dart-backend/angel/tree/master/packages/mongo environment: diff --git a/packages/rethinkdb/README.md b/packages/rethinkdb/README.md index 702444da..7cd95f8e 100644 --- a/packages/rethinkdb/README.md +++ b/packages/rethinkdb/README.md @@ -3,7 +3,7 @@ [![version 1.0.7](https://img.shields.io/badge/pub-1.0.7-brightgreen.svg)](https://pub.dartlang.org/packages/angel_rethink) [![build status](https://travis-ci.org/angel-dart/rethink.svg?branch=master)](https://travis-ci.org/angel-dart/rethink) -RethinkDB-enabled services for the Angel framework. +RethinkDB-enabled service for the Angel3 framework. ## Installation @@ -14,21 +14,16 @@ dependencies: angel3_rethink: ^8.0.0 ``` -`package:rethinkdb_driver2` will be installed as well. +`belatuk-rethinkdb` driver will be used for connecting to RethinkDB. ## Usage -This library exposes one class: `RethinkService`. By default, these services will even -listen to [changefeeds](https://www.rethinkdb.com/docs/changefeeds/ruby/) 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. ;) +This library exposes one class: `RethinkService`. By default, these services will listen to [changefeeds](https://www.rethinkdb.com/docs/changefeeds/ruby/) from the database, which makes them very suitable for WebSocket use. However, only `CREATED`, `UPDATED` and `REMOVED` events will be fired. Technically not +a problem, as it lowers the number of events that need to be handled 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. +`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. ```dart class User extends Model { @@ -37,16 +32,21 @@ class User extends Model { } main() async { - var r = new RethinkDb(); - var conn = await r.connect(); + var r = RethinkDb(); + var conn = await r.connect( + db: 'testDB', + host: "localhost", + port: 28015, + user: "admin", + password: ""); - app.use('/api/users', new RethinkService(conn, r.table('users'))); + app.use('/api/users', RethinkService(conn, r.table('users'))); // Add type de/serialization if you want - app.use('/api/users', new TypedService(new RethinkService(conn, r.table('users')))); + app.use('/api/users', TypedService(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.use('/api/pro_users', RethinkService(conn, r.table('users').filter({'membership': 'pro'}))); app.service('api/users').afterCreated.listen((event) { print("New user: ${event.result}"); @@ -60,17 +60,17 @@ This class interacts with a `Query` (usually a table) and serializes data to and ## RethinkTypedService -Does the same as above, but serializes to and from a target class using `package:json_god` and its support for reflection. +Does the same as above, but serializes to and from a target class using `belatuk_json_serializer` and it supports reflection. ## Querying You can query these services as follows: +```curl /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. +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: diff --git a/packages/rethinkdb/pubspec.yaml b/packages/rethinkdb/pubspec.yaml index aa72467e..d8fd6e7c 100644 --- a/packages/rethinkdb/pubspec.yaml +++ b/packages/rethinkdb/pubspec.yaml @@ -1,7 +1,6 @@ name: angel3_rethinkdb version: 8.0.0 -description: RethinkDB-enabled services for the Angel3 framework. -publish_to: none +description: This is RethinkDB-enabled service for the Angel3 framework. environment: sdk: ">=3.3.0 <4.0.0" homepage: https://angel3-framework.web.app/ @@ -18,8 +17,4 @@ dev_dependencies: logging: ^1.2.0 test: ^1.25.0 lints: ^4.0.0 - -dependency_overrides: - belatuk_rethinkdb: - path: ../../../rethink_db \ No newline at end of file