Associations for Feathers services.
Install the module with: npm install feathers-associations --save
var feathers = require('feathers');
var associations = require('feathers-associations');
var app = feathers().configure(associations)
.use('/users', userService)
.use('/posts', postsService)
.associate('/users/:userId/posts', ['posts']);
Definition and use with REST URIs:
// Both associations should only work if there is a /users service registered already
app.use('/users', userService)
.use('/posts', postsService)
.use('/accounts', accountService);
// Pass service name in an array
// Calls postsService.findAll({ userId: <userId> })
app.associate('/users/:userId/posts', ['posts']);
// Calls userService.get(<userId>) then calls
// accountService.get(user.account)
app.associate('/users/:userId/account', 'accounts');
For SocketIO:
socket.emit('/users/:userId/posts', { userId: 123 }, function(error, posts) {
});
See examples directory.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
(Nothing yet)
Copyright (c) 2014 David Luecke Licensed under the MIT license.