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

add range condition #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add range condition #24

wants to merge 1 commit into from

Conversation

XueSeason
Copy link

定制 where 查询条件时,研究了下源代码,发现仅支持 =IN 操作,本人项目开发到一半,发现不能满足需求,故扩展了 where 对象的能力,更加灵活可控。

@@ -183,14 +183,15 @@ let rows = yield db.select('table-name');
```js
let rows = yield db.select('table-name', {
where: {
type: 'javascript'
type: 'javascript',
date: [{ op: '>=', value: '20170504'}]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date: { op: '>=', value: '20170504'}

这样会更好吧,可以参考一下业务关于 where 的 api 实现。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dead-horse @coolme200 对于 api 有什么好建议吗?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里用数组的考虑是什么?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date >= 100 AND date <= 200 这种需求么?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对,就是这个需求。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好也支持只传一个 object 的场景吧 date: { op: '>=', value: '20170504'}

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@7cb4e75). Click here to learn what that means.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #24   +/-   ##
=========================================
  Coverage          ?   97.53%           
=========================================
  Files             ?        6           
  Lines             ?      284           
  Branches          ?       41           
=========================================
  Hits              ?      277           
  Misses            ?        7           
  Partials          ?        0
Impacted Files Coverage Δ
lib/operator.js 97.36% <60%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7cb4e75...edc28c5. Read the comment docs.

@fengmk2
Copy link
Member

fengmk2 commented Jun 12, 2017

OR 的功能估计也需要考虑一下 eggjs/egg#1035

@musicode
Copy link

几个月过去了,这个 PR 还有下文吗

@wulv
Copy link

wulv commented Apr 12, 2018

这个PR还有下文吗?

@xyeric
Copy link

xyeric commented May 1, 2018

还有LIKE的场景,能不能支持~ @fengmk2

where: {
  key: `LIKE %${keyword}%`
}

@shiny
Copy link

shiny commented May 25, 2018

Any updates?

@Benny233
Copy link

Benny233 commented Sep 6, 2018

哟,or会有吗?需要的老哥们,咱们组队贡献代码吧!?

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

Successfully merging this pull request may close these issues.

9 participants