I want to insert some values in the database but I got an error about syntax as following: sysntax error at or near ":"; How to properly add the replacement? Whrere is this error caused from? I watch also the sequelize documentation here
How make this code work??
here is the code:
const replacements = {
product_code:record.product_code,
ym_product_code:record.ym_product_code,
stock_type:record.stock_type,
stock_name:record.stock_name,
product_name:record.product_name,
product_photo:record.product_photo,
metarial_quality:record.metarial_quality,
explanation:record.explanation,
thickness:record.thickness,
length:record.length,
diameter:record.diameter,
category:record.category,
color:record.color,
unit:record.unit,
height:record.height,
net_kg:record.net_kg,
gross_kg:record.gross_kg,
pieces_in_box:record.pieces_in_box,
volume :record.volume};
const data = await db.sequelize.query(`
SELECT dblink_exec('stecore_conn', '
INSERT INTO materials (
product_code, ym_product_code, stock_type, stock_name, product_name, product_photo,
metarial_quality, explanation, thickness, length, diameter, category, color, unit,
height, net_kg, gross_kg, pieces_in_box, volume
)
VALUES (
:product_code, :ym_product_code, :stock_type, :stock_name, :product_name,
:product_photo, :metarial_quality, :explanation, :thickness, :length, :diameter,
:category, :color, :unit, :height, :net_kg, :gross_kg, :pieces_in_box, :volume
)
');
`, {
logging:console.log,
type: sequelize.QueryTypes.INSERT,
replacements
})