@sophia-iot/database-adapter
Adapter for connecting microservices to different databases
Last updated 4 months ago by sophia-iot .
Original npm · Tarball · package.json
$ cnpm install @sophia-iot/database-adapter 
SYNC missed versions from official npm registry.
  • Sophia database adapter

Since we use moleculer we could easily add one of a few different database mixins to provide restful access to the different databases on offer.

However, I'd like to lock down any unauthorised requests to the database and have so created a database adapter system by which we can leverage the best of the mixin system with the security of the single database access model.

** Usage

~npm i --save @sophia-iot/database-adapter~

#+BEGIN_SRC javascript const getDatabase = require('@sophia-iot/database-adapter');

const database = getDatabase();

console.log(await database.get(id)); #+END_SRC

** Adapters exist for

  • RethinkDB
  • NeDB

** Database access

In the Sophia project, the database should ONLY be accessed through one of these database adapters. This prevents unusual reliance on any one specific feature of a database set.

If and when the microservice requires a different database architecture in order to perform more efficiently in it's task set, this adapter makes it a simple task to switch to the preffered model.

** Writing an adapter

Please include your adapter in the adapters folder, and link it into the index file there.

*** Requirements

Your database adapter must include the following functions:

  • ~get(id)~ Returns: new promise which resolves to the item. Throws: NotFound error if the item does not exist
  • ~remove(id)~ Returns: new promise which resolves to the number of items removed. Throws: NotFound error if the item does not exist
  • ~insert(item = {})~ Returns: new promise which resolves to the item added (with ID).
  • ~list(filters = {})~ Returns: new promise which resolves to an array of matching items
  • ~connect(params = {})~ Returns: New promise which resolves when we are connected
  • ~update(id, changes = {})~ Returns: New promise with the number of items changed
  • ~findOne(filters = {})~ Returns: New promise with the item which matches filters (if any)

Current Tags

  • 0.25.0                                ...           latest (4 months ago)

81 Versions

  • 0.25.0                                ...           4 months ago
  • 0.24.0                                ...           4 months ago
  • 0.23.1                                ...           6 months ago
  • 0.23.0                                ...           6 months ago
  • 0.21.2                                ...           7 months ago
  • 0.21.1                                ...           7 months ago
  • 0.22.0                                ...           8 months ago
  • 0.21.0                                ...           8 months ago
  • 0.20.0                                ...           8 months ago
  • 0.19.4                                ...           9 months ago
  • 0.19.2                                ...           9 months ago
  • 0.19.1                                ...           9 months ago
  • 0.19.0                                ...           9 months ago
  • 0.18.0                                ...           9 months ago
  • 0.17.0                                ...           9 months ago
  • 0.16.0                                ...           9 months ago
  • 0.15.0                                ...           9 months ago
  • 0.14.0                                ...           9 months ago
  • 0.13.5                                ...           9 months ago
  • 0.13.4                                ...           9 months ago
  • 0.13.3                                ...           9 months ago
  • 0.13.2                                ...           10 months ago
  • 0.13.1                                ...           10 months ago
  • 0.13.0                                ...           10 months ago
  • 0.12.1                                ...           10 months ago
  • 0.12.0                                ...           10 months ago
  • 0.10.0                                ...           10 months ago
  • 0.9.3                                ...           10 months ago
  • 0.9.2                                ...           10 months ago
  • 0.9.1                                ...           10 months ago
  • 0.9.0                                ...           10 months ago
  • 0.8.1                                ...           10 months ago
  • 0.8.0                                ...           10 months ago
  • 0.7.0                                ...           10 months ago
  • 0.6.3                                ...           10 months ago
  • 0.6.2                                ...           10 months ago
  • 0.6.1                                ...           10 months ago
  • 0.6.0                                ...           10 months ago
  • 0.5.5                                ...           10 months ago
  • 0.5.4                                ...           10 months ago
  • 0.5.3                                ...           10 months ago
  • 0.5.2                                ...           10 months ago
  • 0.5.1                                ...           10 months ago
  • 0.5.0                                ...           10 months ago
  • 0.4.3                                ...           10 months ago
  • 0.4.2                                ...           10 months ago
  • 0.4.1                                ...           10 months ago
  • 0.4.0                                ...           10 months ago
  • 0.3.0                                ...           10 months ago
  • 0.2.9                                ...           10 months ago
  • 0.2.8                                ...           a year ago
  • 0.2.7                                ...           a year ago
  • 0.2.6                                ...           a year ago
  • 0.2.5                                ...           a year ago
  • 0.2.4                                ...           a year ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.21                                ...           a year ago
  • 0.1.20                                ...           a year ago
  • 0.1.19                                ...           a year ago
  • 0.1.18                                ...           a year ago
  • 0.1.17                                ...           a year ago
  • 0.1.16                                ...           a year ago
  • 0.1.15                                ...           a year ago
  • 0.1.14                                ...           a year ago
  • 0.1.13                                ...           a year ago
  • 0.1.12                                ...           a year ago
  • 0.1.11                                ...           a year ago
  • 0.1.10                                ...           a year ago
  • 0.1.9                                ...           a year ago
  • 0.1.8                                ...           a year ago
  • 0.1.7                                ...           a year ago
  • 0.1.6                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (16)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |