0.25.0 • Published 5 years ago

@sophia-iot/database-adapter v0.25.0

Weekly downloads
-
License
-
Repository
-
Last release
5 years ago
  • 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)
0.25.0

5 years ago

0.24.0

5 years ago

0.23.1

5 years ago

0.23.0

5 years ago

0.21.2

5 years ago

0.21.1

5 years ago

0.22.0

6 years ago

0.21.0

6 years ago

0.20.0

6 years ago

0.19.4

6 years ago

0.19.2

6 years ago

0.19.1

6 years ago

0.19.0

6 years ago

0.18.0

6 years ago

0.17.0

6 years ago

0.16.0

6 years ago

0.15.0

6 years ago

0.14.0

6 years ago

0.13.5

6 years ago

0.13.4

6 years ago

0.13.3

6 years ago

0.13.2

6 years ago

0.13.1

6 years ago

0.13.0

6 years ago

0.12.1

6 years ago

0.12.0

6 years ago

0.10.0

6 years ago

0.9.3

6 years ago

0.9.2

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago