UNPKG

@lantsang/nestjs-tdengine

Version:

NestJS TDengine 驱动

53 lines (52 loc) 2.18 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.QueryUtil = void 0; const common_1 = require("@nestjs/common"); const format_util_1 = require("./format.util"); let QueryUtil = class QueryUtil { constructor(formatUtil) { this.formatUtil = formatUtil; } /** * 解析查询原始数据 * @param param0 查询原始数据 * @returns 解析后的数据 */ resolve({ column_meta: columnMeta, data }) { return data.map(raw => { const result = {}; for (const [index, [column, type]] of columnMeta.entries()) { result[this.formatUtil.underlineToSmallHump(column)] = this.formatUtil.getValue(raw[index], type); } return result; }); } /** * 解析count方法查询原始数据 * @param param0 查询原始数据 * @returns 数量 */ resolveCount({ column_meta: columnMeta, data }) { const [raw] = data; for (const [index, [column, type]] of columnMeta.entries()) { if (this.formatUtil.underlineToSmallHump(column).startsWith('count')) { return this.formatUtil.getValue(raw[index], type); } } return 0; } }; QueryUtil = __decorate([ common_1.Injectable(), __metadata("design:paramtypes", [format_util_1.FormatUtil]) ], QueryUtil); exports.QueryUtil = QueryUtil;