我真的很喜欢将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
发布评论