fix: one-to-one associations didn't work properly

This commit is contained in:
Mahdi Dibaiee 2016-02-07 15:51:44 +03:30
parent 5db3bb4eb3
commit 45d991d1e9
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "hapi-sequelize-crud", "name": "hapi-sequelize-crud",
"version": "1.5.0", "version": "1.5.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

@ -24,7 +24,11 @@ export const get = (server, a, b) => {
if (request.query.include) if (request.query.include)
include = [request.models[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({ include: include.concat({
model: a, model: a,
where: { where: {