From 45d991d1e96c15ce02422bcd53823c69fb5a34a8 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Sun, 7 Feb 2016 15:51:44 +0330 Subject: [PATCH] fix: one-to-one associations didn't work properly --- package.json | 2 +- src/associations/one-to-one.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5035b83..a6ce524 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hapi-sequelize-crud", - "version": "1.5.0", + "version": "1.5.1", "description": "Hapi plugin that automatically generates RESTful API for CRUD", "main": "build/index.js", "config": { diff --git a/src/associations/one-to-one.js b/src/associations/one-to-one.js index 130ed56..1ccd8fc 100644 --- a/src/associations/one-to-one.js +++ b/src/associations/one-to-one.js @@ -24,7 +24,11 @@ export const get = (server, a, b) => { if (request.query.include) include = [request.models[request.query.include]]; - let instance = await b.findOne({ + let where = _.omit(request.query, 'include'); + + let [instance] = await b.findAll({ + where, + include: include.concat({ model: a, where: {