Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting all queries to raw = true sequelize

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?

like image 710
mateeyow Avatar asked Oct 07 '14 04:10

mateeyow


1 Answers

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}})
like image 138
xShirase Avatar answered Oct 03 '22 01:10

xShirase