Answer the question
In order to leave comments, you need to log in
Why are fields added to the database incorrectly?
for(let client of clients) {
const phone = client.PHONE ? client.PHONE[0].VALUE : null;
const email = client.EMAIL ? client.EMAIL[0].VALUE : null;
console.log(clients)
console.log(phone);
const result = await knex("clients").insert({firs_name: client.NAME,
last_name: client.LAST_NAME,
patronymic: client.SECOND_NAME,
role: null,
//phones: knex.raw('array_append(phones, ?)', [phone]),
//emails: knex.raw('array_append(emails, ?)', [email])
})
await knex("clients").update({phones: knex.raw('array_append(phones, ?)', [phone])})
await knex("clients").update({emails: knex.raw('array_append(emails, ?)', [email])});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question