fix(one-to-one): should not require an id for the second model, because there is only one anyways

This commit is contained in:
Mahdi Dibaiee 2016-01-24 15:07:31 +03:30
parent 5e0eeccbac
commit aebff50d0b
3 changed files with 2 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{
"name": "hapi-sequelize-crud",
"version": "1.3.0",
"version": "1.3.1",
"description": "Hapi plugin that automatically generates RESTful API for CRUD",
"main": "build/index.js",
"config": {

View File

@ -7,7 +7,6 @@ let prefix;
export default (server, a, b, options) => {
prefix = options.prefix;
console.log(`${prefix}/associate/${a._singular}/{aid}/${b._singular}/{bid}`);
server.route({
method: 'GET',
path: `${prefix}/associate/${a._singular}/{aid}/${b._singular}/{bid}`,

View File

@ -15,15 +15,11 @@ export default (server, a, b, options) => {
export const get = (server, a, b) => {
server.route({
method: 'GET',
path: `${prefix}/${a._singular}/{aid}/${b._singular}/{bid}`,
path: `${prefix}/${a._singular}/{aid}/${b._singular}`,
@error
async handler(request, reply) {
let instance = await b.findOne({
where: {
id: request.params.bid
},
include: [{
model: a,
where: {