这样做,受影响的行数为零。
const fields = ['name','age', 'createdAt'].filter(field => field !== 'createdAt').map(field => `${field} = ?`).join(', ');
const query = `UPDATE configurations SET ${fields} WHERE id = ? `;
问题出在filter(field => field !== 'createdAt')
,但是如果我删除它,则createdAt将为null。如何忽略createdAt的值(保持先前的值)?