[英]Is there any way to convert the fields of raw Sequelize query into camelcase?
[英]Sequelize does not recognize table with camelCase name when using raw query
我在 sequelize 中使用原始查詢來查詢具有駱駝案例名稱的表中的數據。 代碼看起來像這樣
const activeProducts = await sequelize.query(
`SELECT ap.*, pd.stack_id stack_id, pd.channel_id channel_id, pd.product_type product_type FROM active_products ap
join productDefinitions pd on ap.product_id = pd.id
WHERE active = \'active\'
`,
{ type: QueryTypes.SELECT }
);
console.log(activeProducts)
return activeProducts;
sequelize 似乎無法識別帶有駝峰字母的表名。 它不是查找“productDefinitions”,而是查找“productdefinitions”,這里是 output
Error: relation "productdefinitions" does not exist
我想你正在使用 Postgres。 嘗試用"
您是否嘗試引用表名?
SELECT ap.*, pd.stack_id stack_id, pd.channel_id channel_id, pd.product_type product_type FROM active_products ap
join "productDefinitions" pd on ap.product_id = pd.id
WHERE active = \'active\'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.