将所有查询设置为raw = true sequelize

编程入门 行业动态 更新时间:2024-10-25 00:32:52
本文介绍了将所有查询设置为raw = true sequelize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我真的很喜欢将sequelize用作我的节点应用程序的ORM,但是现在,当默认情况下在查询时它们传递DAO对象时,我有点恼火.如何始终将raw选项设置为true?

I really like using sequelize as my ORM for my node application, but right now, I am kind of irritated when they are passing DAO objects by default when you query. How can I set the raw option to true all the time?

推荐答案

根据文档:

如果您不提供SQL以外的其他参数,则将raw假定为true,并且sequelize将不会尝试对查询结果进行任何格式化.

If you do not provide other arguments than the SQL, raw will be assumed to the true, and sequelize will not try to do any formatting to the results of the query.

话虽如此:

Sequelize对象具有[options.query = {}]可选参数,用于设置sequelize.query的默认选项. 来源

The Sequelize object has a [options.query={}] optional parameter to set default options for sequelize.query. Source

您应该可以使用:

var sequelize = new Sequelize('database', 'username', 'password', {query:{raw:true}})

更多推荐

将所有查询设置为raw = true sequelize

本文发布于:2023-10-23 22:38:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522205.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:设置为   raw   sequelize   true

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!