问题
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?
回答1:
According to the doc :
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.
That being said :
The Sequelize object has a [options.query={}] optional parameter to set default options for sequelize.query. Source
You should be able to use :
var sequelize = new Sequelize('database', 'username', 'password', {query:{raw:true}})
    回答2:
For create you can use this:
Model.create(modelObject)
.then((resultEntity) => {
    const dataObj = resultEntity.get({plain:true})
}
Check this out: Set raw = true on Sequelize Model.create
来源:https://stackoverflow.com/questions/26228499/setting-all-queries-to-raw-true-sequelize