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", "name": "hapi-sequelize-crud",
"version": "1.3.0", "version": "1.3.1",
"description": "Hapi plugin that automatically generates RESTful API for CRUD", "description": "Hapi plugin that automatically generates RESTful API for CRUD",
"main": "build/index.js", "main": "build/index.js",
"config": { "config": {

View File

@ -7,7 +7,6 @@ let prefix;
export default (server, a, b, options) => { export default (server, a, b, options) => {
prefix = options.prefix; prefix = options.prefix;
console.log(`${prefix}/associate/${a._singular}/{aid}/${b._singular}/{bid}`);
server.route({ server.route({
method: 'GET', method: 'GET',
path: `${prefix}/associate/${a._singular}/{aid}/${b._singular}/{bid}`, 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) => { export const get = (server, a, b) => {
server.route({ server.route({
method: 'GET', method: 'GET',
path: `${prefix}/${a._singular}/{aid}/${b._singular}/{bid}`, path: `${prefix}/${a._singular}/{aid}/${b._singular}`,
@error @error
async handler(request, reply) { async handler(request, reply) {
let instance = await b.findOne({ let instance = await b.findOne({
where: {
id: request.params.bid
},
include: [{ include: [{
model: a, model: a,
where: { where: {