-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
修复数据库返回字段只有下划线(aa_bb_cc)方式的问题 #524
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
这个可以通过 |
我知道,但是如果数据量大的情况下,遍历逐条数据修改的性能还不如直接修改sql来得好。 |
你好,切面的话只能后置解决问题,遇到多分表的情况还是解决不了,例如用户表分几十张,然后涉及到跨库,不可能建几十个model 来解决,这是我们团队经过两天研究得到最优的解决方案! |
OK,处理下 eslint 检测报错,执行 |
希望测试下关联模型,我在使用时打开 camel_case 后发现关联模型获取不到关联数据。当关联模型为 HAS_MANY 时,SQL 解析还会出错。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
原有的老项目用的是java,数据库定义的字段为下划线(aa_bb_cc)方式,返回给客户端的字段为驼峰式。现在新的需求用thinkjs实现,我们使用thinkjs是直接由model层获取得数据然后返回,由于数据库定义的是下划线,所以node实现的接口与java返回的数据格式不一致。为了解决这个问题,我在config/db.js加了一个配置camel_case选项,修改model/base.js的parseOptions方法和parseData方法,使其支持返回的字段是下划线( snakeCase )or驼峰式( camelCase )。