refactor: adapt many sql queries for postgresql

This commit is contained in:
Dim145
2024-10-19 02:42:33 +02:00
parent 0527227317
commit 33562fb2c0
9 changed files with 50 additions and 23 deletions

View File

@ -1,4 +1,6 @@
const moment = require('moment');
const moment = require('moment');
const {isPostgres} = require('./config');
const {ref} = require('objection');
module.exports = {
@ -45,6 +47,20 @@ module.exports = {
}
});
return obj;
}
},
/**
* Casts a column to json if using postgres
*
* @param {string} colName
* @returns {string|Objection.ReferenceBuilder}
*/
castJsonIfNeed: function (colName) {
if (isPostgres()) {
return ref(colName).castText();
}
else {
return colName;
}
}
};