feedhenry / fh-db

Apache License 2.0
1 stars 16 forks source link

Rhmap 11672 #18

Closed pb82 closed 7 years ago

pb82 commented 7 years ago

Motivation

Extends the fh-db API with a MongoDB compatible layer on top of shared and dedicated databases. This API can be consumed by the new backend service for the databrowser and provides easy replaceability with the actual MongoDB driver as soon as we don't have to support shared dbs.

The API supports the exact MongoDB driver semantics, including promises and cursors. Naming conventions for shared dbs are adhered in all API calls. The following functions are implemented:

#createCollection
#dropCollection
#listCollections
#collection
#createIndex
#renameCollection
#close

Advanced API for CRUD operations can be easily used for shared and dedicated dbs by using the collection function and running queries on collections:

var localdb = require('fh-db');
localdb.createMongoCompatApi({
  __dbperapp: <true|false>,
  __fhdb: <passed by fh-mbaas-api, only required for shared db>,
  connectionUrl: <connection url for shared or dedicated database>
}).then(function (db) {
  // db is now either a native mongodb connection or a compatible wrapper API
  db.collection("user").find(...);
});

ping @wei-lee @rachael-oregan @sedroche

wei-lee commented 7 years ago

LGTM. Some comments but excellent work. 👍

fh-qube commented 7 years ago

SonarQube analysis reported 8 issues:

Watch the comments in this conversation to review them. Note: the following issues could not be reported as comments because they are located on lines that are not displayed in this pull request: