Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not set condition for children #230

Open
thangnd238 opened this issue Jan 28, 2021 · 1 comment
Open

Can not set condition for children #230

thangnd238 opened this issue Jan 28, 2021 · 1 comment

Comments

@thangnd238
Copy link

thangnd238 commented Jan 28, 2021

This is my db
image

I want to set condition for children, but i receive this error: "Parent ID 2 not found in result set" because the record with id = 2 has status = 2, so can not get in result set. How can i fix it?. This is my code:

data = await Menu.findAll( {
  hierarchy: true,
  where: { status: 1 },
  required: false,
  include: [
    { model: Category },
  ]
}, {
  where: {
    project: project,
    hierarchy_level: 1,
    status: [
      common_const.MENU_STATUS.ACTIVE,
      common_const.MENU_STATUS.DEACTIVE
    ]
  },
} );
@overlookmotel
Copy link
Owner

@thangnd238 I have reformatted your code to make it more readable. But it doesn't appear to be syntactical - you are calling .findAll() with 2 arguments which (unless Sequelize has changed recently) isn't correct. Can you please check the code is correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants