简体   繁体   中英

sequelize: How to log raw query

I use sequelize with postgresql and logger winston . Here is my code:

logging: e => logger('sequelize').info(e)

this logs the result like this:

INSERT INTO "test" ("id","aa","bb","cc") VALUES (DEFAULT,$1,$2,$3) RETURNING *; // I don't want this

how to change so that the output will like this?

INSERT INTO "test" ("id","aa","bb","cc") VALUES (DEFAULT,"AA","BB","CC") RETURNING *; // I want this 

There is an option for this in the Sequelize constructor:

logQueryParameters : true

It does work, but you might have to play around with it to get the log formatted the way you want. Unfortunately, I can't find any good examples. There was a recent bug fix of this feature, so make sure your package is current.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM