I'm encountring this issue and i'm running out of time so please if anyone could help: I want to insert this data:
const data= {
id:user.id,
choice:'SWOT',
label:['Strengths','Weaknesses','Opportunities','Threats'],
results:[45,5,20,30],
description:'My first Strategic Analysis'}
into this table:
analyses (
id serial primary key,
userID integer not null,
choice varchar(25) not null,
Label text ARRAY,
Results integer ARRAY,
description varchar(200),
FOREIGN KEY (userID) REFERENCES users (id)
);
Using knex, this should be smth like:
db('analyses').insert({
userid: data.id,
choice: data.choice,
Label: data.labelG,
Results: data.resultG,
description: data.description
})
Since this syntax doesn't work for ARRAY types I wonder how to do it ? Some suggested to use knex.raw() however I coudn't get the right syntax for that Any help?
data.labelGanddata.resultG, but you are initializingdata.labelanddata.result