0.25.0 • Published 4 years ago

@sophia-iot/database-adapter v0.25.0

Weekly downloads
-
License
-
Repository
-
Last release
4 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

4 years ago

0.24.0

4 years ago

0.23.1

4 years ago

0.23.0

4 years ago

0.21.2

4 years ago

0.21.1

4 years ago

0.22.0

4 years ago

0.21.0

4 years ago

0.20.0

4 years ago

0.19.4

4 years ago

0.19.2

4 years ago

0.19.1

4 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.17.0

4 years ago

0.16.0

4 years ago

0.15.0

4 years ago

0.14.0

4 years ago

0.13.5

4 years ago

0.13.4

4 years ago

0.13.3

5 years ago

0.13.2

5 years ago

0.13.1

5 years ago

0.13.0

5 years ago

0.12.1

5 years ago

0.12.0

5 years ago

0.10.0

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago