moleculer-adapter-feathers
Moleculer adapter to import feathers services. That includes:
- MongoDB
- Blob store
- Bookshelf
- CouchDB
- Elasticsearch
- Knex
- Mongoose
- NeDB
- RethinkDB
- Sequalize
- Waterline
- and many others
Install
$ npm install moleculer-adapter-feathers --save
Usage (example with Knex)
const Feathers = ;const ServiceBroker = ;const feathersKnex = ;const knex = ; const broker = ; // Create a DB service via knex for `user` entitiesbroker; brokerstart// Create a new user // Get all users;
Settings
Property | Type | Default | Description |
---|---|---|---|
adapter |
Object | Function |
required | Feathers Knex service adapter. |
hooks |
Object |
{} |
Object containing before and after hooks. |
options |
Object |
{} |
Options passed to Feathers service adapter. |
Hooks
Hooks work just as they do in Feathers. They are passed down to a service in settings.feathers.hooks
.
users.service.js
moduleexports = ... settings: feathers: adapter: feathersKnex hooks: options: name: "users" Model: client: "pg" connection: ... ...
hooks.js
moduleexports = before: create: { console return hook } find: get: update: patch: remove: after: create: find: get: update: patch: remove:
Actions
Standard Feathers actions are exposed: create
, get
, find
, update
, patch
, remove
with all the standard Feathers parameters. Actions can be overwritten.
Methods
Feathers service methods can be accessed directly via this.create
, this.find
and etc.
create
Create an object in a service.
Parameters
Property | Type | Default | Description |
---|---|---|---|
* |
Any |
{} |
Object to be created. |
Results
Type: Object
Created object (or any other service response).
find
Find objects by a provided query, if any.
Parameters
Property | Type | Default | Description |
---|---|---|---|
* |
Any |
{} |
Query specified by the service. |
Results
Type: Array[Object]
Array of results.
get
Get object in the service by a provided (unique) ID.
Parameters
Property | Type | Default | Description |
---|---|---|---|
id |
String | Number |
required | Object ID. |
Results
Type: Object
Object found by the ID.
patch
Changes the properties of an object.
Parameters
Property | Type | Default | Description |
---|---|---|---|
id |
String | Number |
required | Object ID. |
* |
Any |
{} |
Values to be patched. |
Results
Type: Object
Object patched.
update
Overwrites an object's properties.
Parameters
Property | Type | Default | Description |
---|---|---|---|
id |
String | Number |
required | Object ID. |
* |
Any |
{} |
Rest of the object. |
Results
Type: Object
Object updated.
remove
Remove object by ID.
Parameters
Property | Type | Default | Description |
---|---|---|---|
id |
String | Number |
required | Object ID. |
Results
Type: Object
Object removed.