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

How to use or in include? #10761

Closed
651778286 opened this issue Apr 12, 2019 · 3 comments
Closed

How to use or in include? #10761

651778286 opened this issue Apr 12, 2019 · 3 comments

Comments

@651778286
Copy link

How to implement the goal like this mysql example ?

SELECT `Course`.`id`, `Course`.`name`, `Course`.`description`, `Course`.`thumbnail`, `Course`.`program`
	, `Course`.`free`, `Course`.`state`, `Course`.`created_at`, `Course`.`updated_at`, `Course`.`deleted_at`
	, `Organizations`.`id` AS `Organizations.id`, `Organizations`.`name` AS `Organizations.name`, `Organizations`.`type` AS `Organizations.type`, `Organizations`.`created_at` AS `Organizations.created_at`, `Organizations`.`updated_at` AS `Organizations.updated_at`
	, `Organizations`.`deleted_at` AS `Organizations.deleted_at`, `Organizations`.`district_id` AS `Organizations.district_id`, `Organizations->Organization_Course`.`created_at` AS `Organizations.Organization_Course.created_at`, `Organizations->Organization_Course`.`updated_at` AS `Organizations.Organization_Course.updated_at`, `Organizations->Organization_Course`.`deleted_at` AS `Organizations.Organization_Course.deleted_at`
	, `Organizations->Organization_Course`.`course_id` AS `Organizations.Organization_Course.course_id`, `Organizations->Organization_Course`.`organization_id` AS `Organizations.Organization_Course.organization_id`
FROM `t_course` `Course`
	INNER JOIN (`r_organization_course` `Organizations->Organization_Course`
		INNER JOIN `t_organization` `Organizations`
		ON `Organizations`.`id` = `Organizations->Organization_Course`.`organization_id`
			AND (`Organizations->Organization_Course`.`deleted_at` > '2019-04-12 21:18:04'
				OR `Organizations->Organization_Course`.`deleted_at` IS NULL))
	ON `Course`.`id` = `Organizations->Organization_Course`.`course_id`
		AND ((`Organizations`.`deleted_at` > '2019-04-12 21:18:04'
				OR `Organizations`.`deleted_at` IS NULL)
			AND (`Organizations`.`id` = 3 or `Course`.`free` = 1))
WHERE (`Course`.`deleted_at` > '2019-04-12 21:18:04'
		OR `Course`.`deleted_at` IS NULL);

And here's the key thing: "AND (Organizations.id = 3 or Course.free = 1))"

@sbonami
Copy link
Contributor

sbonami commented Apr 12, 2019

Questions like these are best suited for StackOverflow. Sequelize's Github issues are reserved for issues or feature requests on the library itself, not specific use-cases or implementations.

They've even got a tag set up: https://stackoverflow.com/questions/tagged/sequelize.js

@651778286
Copy link
Author

Questions like these are best suited for StackOverflow. Sequelize's Github issues are reserved for issues or feature requests on the library itself, not specific use-cases or implementations.

They've even got a tag set up: https://stackoverflow.com/questions/tagged/sequelize.js

OK, Thank you anyway.I will do it

@sushantdhiman
Copy link
Contributor

Please use Github Issue Tracker only for reporting bugs, requesting new features or discussions. Ask questions on Stackoverflow sequelize.js tag or Slack. While I would like to help answer any questions but it still take too much time.

If you are reporting a bug please isolate it as SSCCE, present it nicely and follow issue template. This will help maintainers and contributors understand your issue quickly.

If you are requesting a feature spend some time to properly present your use case with some examples, current and expected outcome.

( What is SSCCE ? You can find template for Sequelize here )

A few good example of SSCCE

  1. ResourceRequest timed out - connection not reestablished after db restarted #8014 (comment)
  2. removeAttribute('id') results in undefined: null data value #7318 (comment)
  3. toJSON converting booleans to "t" (true) or "f" (false) #8749 (comment)

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

3 participants