(tableName, options, attributeSelector, Model)
| 1027 | } |
| 1028 | |
| 1029 | async rawSelect(tableName, options, attributeSelector, Model) { |
| 1030 | options = Utils.cloneDeep(options); |
| 1031 | options = _.defaults(options, { |
| 1032 | raw: true, |
| 1033 | plain: true, |
| 1034 | type: QueryTypes.SELECT |
| 1035 | }); |
| 1036 | |
| 1037 | const sql = this.queryGenerator.selectQuery(tableName, options, Model); |
| 1038 | |
| 1039 | if (attributeSelector === undefined) { |
| 1040 | throw new Error('Please pass an attribute selector!'); |
| 1041 | } |
| 1042 | |
| 1043 | const data = await this.sequelize.query(sql, options); |
| 1044 | if (!options.plain) { |
| 1045 | return data; |
| 1046 | } |
| 1047 | |
| 1048 | const result = data ? data[attributeSelector] : null; |
| 1049 | |
| 1050 | if (!options || !options.dataType) { |
| 1051 | return result; |
| 1052 | } |
| 1053 | |
| 1054 | const dataType = options.dataType; |
| 1055 | |
| 1056 | if (dataType instanceof DataTypes.DECIMAL || dataType instanceof DataTypes.FLOAT) { |
| 1057 | if (result !== null) { |
| 1058 | return parseFloat(result); |
| 1059 | } |
| 1060 | } |
| 1061 | if (dataType instanceof DataTypes.INTEGER || dataType instanceof DataTypes.BIGINT) { |
| 1062 | if (result !== null) { |
| 1063 | return parseInt(result, 10); |
| 1064 | } |
| 1065 | } |
| 1066 | if (dataType instanceof DataTypes.DATE) { |
| 1067 | if (result !== null && !(result instanceof Date)) { |
| 1068 | return new Date(result); |
| 1069 | } |
| 1070 | } |
| 1071 | return result; |
| 1072 | } |
| 1073 | |
| 1074 | async createTrigger( |
| 1075 | tableName, |
no test coverage detected