Renaming database primary key

This commit is contained in:
2021-04-23 21:20:22 +10:00
parent 0e88c9e64c
commit 370d7905eb
5 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ const { chatlog, reports } = require('../database/models');
const route = async (req, res) => {
const reps = await reports.destroy({
where: {
chatlogId: req.body.chatlogId
chatlogIndex: req.body.chatlogIndex
}
});
+2 -2
View File
@@ -7,14 +7,14 @@ const route = async (req, res) => {
model: chatlog,
required: true
}],
order: ['chatlogId']
order: ['chatlogIndex']
});
//collate
const response = [];
for(let i = 0; i < reps.length; i++) {
//new chatlog
if (response.length == 0 || response[response.length - 1].chatlogId != reps[i].chatlogId) {
if (response.length == 0 || response[response.length - 1].chatlogIndex != reps[i].chatlogIndex) {
response.push(reps[i]);
response[response.length - 1].reporter = [response[response.length - 1].reporter]; //reporters in an array
continue;