MCPcopy
hub / github.com/sequelize/sequelize / rawSelect

Method rawSelect

lib/dialects/abstract/query-interface.js:1006–1049  ·  view source on GitHub ↗
(tableName, options, attributeSelector, Model)

Source from the content-addressed store, hash-verified

1004 }
1005
1006 async rawSelect(tableName, options, attributeSelector, Model) {
1007 options = Utils.cloneDeep(options);
1008 options = _.defaults(options, {
1009 raw: true,
1010 plain: true,
1011 type: QueryTypes.SELECT
1012 });
1013
1014 const sql = this.queryGenerator.selectQuery(tableName, options, Model);
1015
1016 if (attributeSelector === undefined) {
1017 throw new Error('Please pass an attribute selector!');
1018 }
1019
1020 const data = await this.sequelize.query(sql, options);
1021 if (!options.plain) {
1022 return data;
1023 }
1024
1025 const result = data ? data[attributeSelector] : null;
1026
1027 if (!options || !options.dataType) {
1028 return result;
1029 }
1030
1031 const dataType = options.dataType;
1032
1033 if (dataType instanceof DataTypes.DECIMAL || dataType instanceof DataTypes.FLOAT) {
1034 if (result !== null) {
1035 return parseFloat(result);
1036 }
1037 }
1038 if (dataType instanceof DataTypes.INTEGER || dataType instanceof DataTypes.BIGINT) {
1039 if (result !== null) {
1040 return parseInt(result, 10);
1041 }
1042 }
1043 if (dataType instanceof DataTypes.DATE) {
1044 if (result !== null && !(result instanceof Date)) {
1045 return new Date(result);
1046 }
1047 }
1048 return result;
1049 }
1050
1051 async createTrigger(
1052 tableName,

Callers 1

aggregateMethod · 0.80

Calls 2

selectQueryMethod · 0.80
queryMethod · 0.45

Tested by

no test coverage detected