JavaScript
x
11
11
1
query =
2
'insert into ' +
3
table +
4
"( replyDate) values('" +
5
event.state.session.lastMessages
6
.map(function(elem) {
7
return elem.replyDate
8
})
9
.join(',') +
10
"')"
11
I have a table called messages which has column called replyDate.
The event.state.session.lastMessages contains a list of javascript object like so :
[ { eventId: '14337275205243615', incomingPreview: 'bonjour', replyConfidence: 1, replySource: 'dialogManager', replyDate: '2021-05-04T16:40:07.242Z', replyPreview: '#!builtin_single-choice-mrFFU_' } ]
I want to save in my DB the values replyDate, but i get the error:
JavaScript
1
3
1
Executing: insert into messages( replyDate) values('2021-05-07T11:33:36.721Z,2021-05-07T11:33:39.704Z,2021-05-07T11:33:42.414Z,2021-05-07T11:33:42.422Z,2021-05-07T11:33:49.454Z')
2
error: la colonne « replydate » de la relation « messages » n'existe pas
3
Advertisement
Answer
If you have table names with upper case you have to enclose the table with double quotes
JavaScript
1
2
1
insert into messages( "replyDate") values('2021-05-07T11:33:36.721Z'),('2021-05-07T11:33:39.704Z'),('2021-05-07T11:33:42.414Z'),('2021-05-07T11:33:42.422Z'),('2021-05-07T11:33:49.454Z')
2