UNPKG

pao-aop-server

Version:

基于pao-aop的服务端框架

789 lines (787 loc) 35.1 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); 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); }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "mongodb", "../../base", "pao-aop"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var mongodb_1 = require("mongodb"); var base_1 = require("../../base"); var pao_aop_1 = require("pao-aop"); /** 时间匹配正则表达式 */ var DATE_REGEXP = /__Date__/; /** 时间类型自定义 */ var DATE_TYPE_SELF = '__Date__'; /** 时间类型判断条件 */ var DATE_TYPE_STRING = '[object Date]'; /** 逻辑运算符 */ var LogicKeys; (function (LogicKeys) { LogicKeys[LogicKeys["AND"] = 0] = "AND"; LogicKeys[LogicKeys["OR"] = 1] = "OR"; })(LogicKeys = exports.LogicKeys || (exports.LogicKeys = {})); /** * 名称:过滤器 * @description 用于描述Mongo数据操作的过滤器 * @author huyl */ var BaseMongoDataFilter = /** @class */ (function (_super) { __extends(BaseMongoDataFilter, _super); /** * 过滤器 * @param name 名称 * @param childrenFilters 子过滤器 */ function BaseMongoDataFilter(name, childrenFilters) { var _this = _super.call(this) || this; _this.name = name; _this.childrenFilters = childrenFilters; return _this; } /** 获取提条件 */ BaseMongoDataFilter.prototype.getCondition = function (paramValues) { var and = { $and: [] }, or = { $or: [] }; for (var index = 0, len = this.childrenFilters.length; index < len; index++) { var childrenFilter = this.childrenFilters[index]; var logicKey = this.getLogicKey(); var filterJson = childrenFilter.getCondition(paramValues); if (!filterJson) { continue; } // AND 逻辑 if (!logicKey || logicKey === LogicKeys.AND) { and.$and.push(filterJson); } // OR 逻辑 if (logicKey === LogicKeys.OR) { or.$or.push(filterJson); } } if (or.$or.length > 0) { return pao_aop_1.extend(and, or, true); } else { return and; } }; /** 获取逻辑运算符 */ BaseMongoDataFilter.prototype.getLogicKey = function () { // 默认AND逻辑 return LogicKeys.AND; }; BaseMongoDataFilter = __decorate([ pao_aop_1.addon('BaseMongoDataFilter', 'Mongo过滤器基类', '用于描述Mongo数据操作的过滤器'), __metadata("design:paramtypes", [String, Array]) ], BaseMongoDataFilter); return BaseMongoDataFilter; }(pao_aop_1.BaseAddon)); exports.BaseMongoDataFilter = BaseMongoDataFilter; /** * 名称:And逻辑过滤器 * @description 用于描述 Mongo 数据操作 AND 逻辑过滤器 * @author huyl */ var AndMongoDataFilter = /** @class */ (function (_super) { __extends(AndMongoDataFilter, _super); /** * And逻辑过滤器 * @param name 名称 * @param childrenFilters 子过滤器 */ function AndMongoDataFilter(name, childrenFilters) { var _this = _super.call(this, name, childrenFilters) || this; _this.name = name; _this.childrenFilters = childrenFilters; return _this; } AndMongoDataFilter.prototype.getLogicKey = function () { return LogicKeys.AND; }; AndMongoDataFilter = __decorate([ pao_aop_1.addon('AndMongoDataFilter', 'And逻辑过滤器', '用于描述 Mongo 数据操作 AND 逻辑过滤器'), __metadata("design:paramtypes", [String, Array]) ], AndMongoDataFilter); return AndMongoDataFilter; }(BaseMongoDataFilter)); exports.AndMongoDataFilter = AndMongoDataFilter; /** * 名称:Or逻辑过滤器 * @description 用于描述 Mongo 数据操作 OR 逻辑过滤器 * @author huyl */ var OrMongoDataFilter = /** @class */ (function (_super) { __extends(OrMongoDataFilter, _super); /** * And逻辑过滤器 * @param name 名称 * @param childrenFilters 子过滤器 */ function OrMongoDataFilter(name, childrenFilters) { var _this = _super.call(this, name, childrenFilters) || this; _this.name = name; _this.childrenFilters = childrenFilters; return _this; } OrMongoDataFilter.prototype.getLogicKey = function () { return LogicKeys.OR; }; OrMongoDataFilter = __decorate([ pao_aop_1.addon('OrMongoDataFilter', 'Or逻辑过滤器', '用于描述 Mongo 数据操作 OR 逻辑过滤器'), __metadata("design:paramtypes", [String, Array]) ], OrMongoDataFilter); return OrMongoDataFilter; }(BaseMongoDataFilter)); exports.OrMongoDataFilter = OrMongoDataFilter; /** * 数据类型 */ var DataType; (function (DataType) { DataType[DataType["Date"] = 0] = "Date"; DataType[DataType["String"] = 1] = "String"; DataType[DataType["Number"] = 2] = "Number"; })(DataType = exports.DataType || (exports.DataType = {})); /** * 名称:字符串条件语句 * @description 用于Mongo数据操作条件的最基础的语句 * @author huyl */ var StringMongoDataFilter = /** @class */ (function (_super) { __extends(StringMongoDataFilter, _super); /** * 字符串条件语句 * @param name 名称 * @param key 字段名称 * @param condition 条件 * @param dataType 数据类型 */ function StringMongoDataFilter(name, key, condition, dataType) { var _this = _super.call(this, name) || this; _this.key = key; _this.condition = condition; if (typeof dataType === 'undefined') { _this.dataType = DataType.String; } _this.dataType = dataType; return _this; } StringMongoDataFilter.prototype.getCondition = function (paramValues) { if (!paramValues || !paramValues[this.key]) { return undefined; } var value = paramValues[this.key]; var filterString = this.format(this.condition, value); return JSON.parse(filterString, function (key, value) { var reg = new RegExp(DATE_REGEXP); if (reg.test(value)) { return new Date(value.replace(reg, '')); } return value; }); }; /** * 字符串格式化 * @description 需要处理特殊格式,如时间等 */ StringMongoDataFilter.prototype.format = function (origin) { var _this = this; var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } //如果是时间 return origin.replace(/\{([1-9]\d*|0)\}/g, function (s, i) { if (_this.dataType === DataType.Date) { var temp = []; temp.push(DATE_TYPE_SELF, args[i].toUTCString()); return "\"" + temp.join('') + "\""; } return args[i]; }); }; StringMongoDataFilter = __decorate([ pao_aop_1.addon('StringMongoDataFilter', '字符串条件语句', '用于Mongo数据操作条件的最基础的语句'), __metadata("design:paramtypes", [String, String, String, Number]) ], StringMongoDataFilter); return StringMongoDataFilter; }(BaseMongoDataFilter)); exports.StringMongoDataFilter = StringMongoDataFilter; /** * 名称:集合 * @description 用于描述Mongo数据集合的对象 * @author huyl */ var BaseMongoCollection = /** @class */ (function (_super) { __extends(BaseMongoCollection, _super); /** * 命令 * @param {string} name 名称 * @param {string} collection 集合名称 * @param {Object} filters 过滤器 */ function BaseMongoCollection(name, collection, primaryKeys, filters) { var _this = _super.call(this) || this; _this.name = name; _this.collection = collection; _this.primaryKeys = primaryKeys; _this.filters = filters; return _this; } /** * 获取条件 */ BaseMongoCollection.prototype.getCondition = function (filterName, paramValues) { if (!paramValues || !this.filters || Object.keys(paramValues).length === 0) { return {}; } return this.filters[filterName].filter.getCondition(paramValues); }; BaseMongoCollection = __decorate([ pao_aop_1.addon('BaseMongoCollection', '集合', '用于描述Mongo数据集合的对象'), __metadata("design:paramtypes", [String, String, Array, Object]) ], BaseMongoCollection); return BaseMongoCollection; }(pao_aop_1.BaseAddon)); exports.BaseMongoCollection = BaseMongoCollection; /** * 名称:Mongo DB 连接池 * @description 用于操作Mongo DB连接信息的对象 * @author huyl */ var MongoConnectionPool = /** @class */ (function (_super) { __extends(MongoConnectionPool, _super); /** Mongo DB 连接池 */ function MongoConnectionPool(conn, database) { var _this = _super.call(this) || this; _this.conn = conn; _this.database = database; return _this; } Object.defineProperty(MongoConnectionPool.prototype, "uri", { /** 连接信息 */ get: function () { if (typeof this.conn === 'object') { return "mongodb://" + this.conn.ip + ":" + this.conn.port + (this.conn.database ? "/" + this.conn.database : null); } if (typeof this.conn === 'string') { return this.conn; } return undefined; }, enumerable: true, configurable: true }); Object.defineProperty(MongoConnectionPool.prototype, "connection", { /** 创建连接 */ get: function () { return mongodb_1.MongoClient.connect(this.uri, { useNewUrlParser: true }); }, enumerable: true, configurable: true }); Object.defineProperty(MongoConnectionPool.prototype, "dbName", { /** 获取数据库名称 */ get: function () { return typeof this.conn === 'string' ? this.database : typeof this.conn === 'object' ? this.conn.database : undefined; }, enumerable: true, configurable: true }); MongoConnectionPool = __decorate([ pao_aop_1.addon('MongoConnectionPool', 'Mongo DB 连接池', '用于操作Mongo DB连接信息的对象'), __metadata("design:paramtypes", [Object, String]) ], MongoConnectionPool); return MongoConnectionPool; }(pao_aop_1.BaseAddon)); exports.MongoConnectionPool = MongoConnectionPool; /** * 名称:Mongo DB 数据存储 * @description 完成Mongo DB主要增删查改等操作 * @author huyl */ var MongoStorage = /** @class */ (function (_super) { __extends(MongoStorage, _super); /** Mongo DB 数据存储 */ function MongoStorage(pool) { var _this = _super.call(this) || this; _this.pool = pool; /** Mongo 数据库每个文本的_id */ _this.obj_id_key = '_id'; /** * * @param primaryKeys 主键关键字 * @param object */ _this.getFilterByObject = function (primaryKeys, object) { var _a; // TODO: PAO, 此处需要从object中通过command的主键来获取过滤器 if (!primaryKeys || primaryKeys.length === 0) { // 如果不存在主键则返回MongoDB默认主键 // 确保_id为ObjectId类型 return _a = {}, _a[_this.obj_id_key] = new mongodb_1.ObjectId(object[_this.obj_id_key]), _a; } var where = {}; for (var _i = 0, primaryKeys_1 = primaryKeys; _i < primaryKeys_1.length; _i++) { var key = primaryKeys_1[_i]; // 当主键存在object时添加 if (key in object) { where[key] = object[key]; } } return where; }; return _this; } /** * 查询 * @param {string} collection 集合名称 * @param {{}} where 条件 * @param {{}} option 统计配置 * @returns {Promise<any[]>} 结果 */ MongoStorage.prototype.select = function (collection, where, option) { return __awaiter(this, void 0, void 0, function () { var client, skip, limit, condition, db, col, doc, ret; var _this = this; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.pool.connection]; case 1: client = _a.sent(); skip = option && option.skip ? option.skip : 0, limit = option && option.limit ? option.limit : 0, condition = where ? where : {}; db = client.db(this.pool.dbName); col = db.collection(collection); _a.label = 2; case 2: _a.trys.push([2, , 4, 5]); return [4 /*yield*/, col .find(condition) // 条件筛选 .skip(skip) // 跳过行数,默认0 .limit(limit) // 返回行数,默认0,查找全部 .toArray()]; case 3: doc = _a.sent(); ret = doc.map(function (obj) { if (_this.obj_id_key in obj) { var _id = obj[_this.obj_id_key]; obj[_this.obj_id_key] = _id.toHexString && _id.toHexString(); } return obj; }); return [2 /*return*/, ret]; case 4: client.close(); // 关闭客户端连接 return [7 /*endfinally*/]; case 5: return [2 /*return*/]; } }); }); }; /** * 更新 * @param {string} collection 集合名称 * @param {any[]} document 文档集合 * @returns {Promise<WriteOpResult>} 结果 */ MongoStorage.prototype.update = function (collection, documents) { return __awaiter(this, void 0, void 0, function () { var client, db, updateCount, _i, documents_1, doc, writeOpResult; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.pool.connection]; case 1: client = _a.sent(); db = client.db(this.pool.dbName); _a.label = 2; case 2: _a.trys.push([2, , 7, 8]); updateCount = 0; _i = 0, documents_1 = documents; _a.label = 3; case 3: if (!(_i < documents_1.length)) return [3 /*break*/, 6]; doc = documents_1[_i]; // _id为字符串时,需要转换为ObjectID才能匹配原数据 if (this.obj_id_key in doc && typeof doc[this.obj_id_key] === 'string') { doc[this.obj_id_key] = new mongodb_1.ObjectId(doc[this.obj_id_key]); } return [4 /*yield*/, db.collection(collection).replaceOne({}, doc)]; case 4: writeOpResult = _a.sent(); updateCount += writeOpResult.result.n; _a.label = 5; case 5: _i++; return [3 /*break*/, 3]; case 6: return [2 /*return*/, updateCount]; case 7: client.close(); return [7 /*endfinally*/]; case 8: return [2 /*return*/]; } }); }); }; /** * 添加 * @param collection 集合名称 * @param documents 文档列表 */ MongoStorage.prototype.insert = function (collection, documents) { return __awaiter(this, void 0, void 0, function () { var client, db, col, value; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.pool.connection]; case 1: client = _a.sent(); db = client.db(this.pool.dbName); _a.label = 2; case 2: _a.trys.push([2, , 5, 6]); return [4 /*yield*/, db.createCollection(collection)]; case 3: col = _a.sent(); return [4 /*yield*/, col.insertMany(documents)]; case 4: value = _a.sent(); return [2 /*return*/, value]; case 5: client.close(); return [7 /*endfinally*/]; case 6: return [2 /*return*/]; } }); }); }; /** * 删除 * @param {string} collection 集合名称 * @param {string[]} primaryKeys 主键列表 * @param {Object[]} objects 对象 * @returns {Promise<any>} 结果 */ MongoStorage.prototype.delete = function (collection, primaryKeys, objects) { return __awaiter(this, void 0, void 0, function () { var client, db, deleteCount, _i, objects_1, object, where, value; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.pool.connection]; case 1: client = _a.sent(); db = client.db(this.pool.dbName); deleteCount = 0; _a.label = 2; case 2: _a.trys.push([2, , 7, 8]); if (!objects) return [3 /*break*/, 6]; _i = 0, objects_1 = objects; _a.label = 3; case 3: if (!(_i < objects_1.length)) return [3 /*break*/, 6]; object = objects_1[_i]; where = this.getFilterByObject(primaryKeys, object); return [4 /*yield*/, db.collection(collection).deleteOne(where)]; case 4: value = _a.sent(); deleteCount += value.deletedCount; _a.label = 5; case 5: _i++; return [3 /*break*/, 3]; case 6: return [2 /*return*/, deleteCount]; case 7: client.close(); return [7 /*endfinally*/]; case 8: return [2 /*return*/]; } }); }); }; /** * 获取集合文档数量 * @param collection 集合名称 * @param where 条件 */ MongoStorage.prototype.count = function (collection, where) { return __awaiter(this, void 0, void 0, function () { var client, db, condition, value; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.pool.connection]; case 1: client = _a.sent(); db = client.db(this.pool.dbName); _a.label = 2; case 2: _a.trys.push([2, , 4, 5]); condition = where ? where : {}; return [4 /*yield*/, db.collection(collection).count(condition)]; case 3: value = _a.sent(); return [2 /*return*/, value]; case 4: client.close(); return [7 /*endfinally*/]; case 5: return [2 /*return*/]; } }); }); }; MongoStorage = __decorate([ pao_aop_1.addon('MongoStorage', 'Mongo DB 数据存储', '完成Mongo DB主要增删查改等操作'), __metadata("design:paramtypes", [MongoConnectionPool]) ], MongoStorage); return MongoStorage; }(pao_aop_1.BaseAddon)); exports.MongoStorage = MongoStorage; /** * 名称:Mongo 数据查询服务 * @description 提供Mongo数据库查询的服务 * @author huyl */ var MongoQueryService = /** @class */ (function (_super) { __extends(MongoQueryService, _super); /** * Mongo 数据服务 * @param storage 数据存储 */ function MongoQueryService(storage) { var _this = _super.call(this) || this; _this.storage = storage; /** * 获取命令和过滤器名称 * @param commandID 命令ID */ _this.getCommandAndFilterName = function (commandID) { var commands = commandID.split(".", 2); var cmd = _this.checkValidity(commands[0]); var filterName = commands[1]; return { command: cmd, filterName: filterName, primaryKeys: cmd.primaryKeys }; }; _this.collectionList = {}; return _this; } /** * 检查合法性 * @protected * @param {string} commandString 命令ID * @returns {BaseMongoCollection} */ MongoQueryService.prototype.checkValidity = function (commandString) { if (!this.storage) { throw new Error('当前服务没有数据库存储'); } if (!commandString) { throw new Error('查询的命令不能为空'); } // 根据命令ID获取命令 var cmd = this.collectionList[commandString]; if (!cmd) { throw new Error("\u5F53\u524D\u670D\u52A1\u6CA1\u6709[" + commandString + "]\u7684\u547D\u4EE4"); } if (!cmd.collection) { throw new Error("\u8BE5\u547D\u4EE4\u4E0D\u5B58\u5728\u96C6\u5408\u540D\u79F0"); } return cmd; }; /** * 获取支持的方法 */ MongoQueryService.prototype.getSupportMethods = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, ['query', 'update', 'updateMany', 'insert', 'delete', 'deleteMany', 'count']]; }); }); }; /** * 查询 * @param {string} commandID 命令ID * @param {{}} paramValues 参数 * @param {number} startIndex 开始索引 * @param {number} maxCount 最大行数,默认0为查询全部数据 */ MongoQueryService.prototype.query = function (commandID, paramValues, startIndex, maxCount) { if (startIndex === void 0) { startIndex = 0; } if (maxCount === void 0) { maxCount = 0; } return __awaiter(this, void 0, void 0, function () { var _a, command, filterName, where; return __generator(this, function (_b) { switch (_b.label) { case 0: _a = this.getCommandAndFilterName(commandID), command = _a.command, filterName = _a.filterName; where = command.getCondition(filterName, paramValues); return [4 /*yield*/, this.storage.select(command.collection, where, { skip: startIndex, limit: maxCount })]; case 1: // 通过存储执行查询 return [2 /*return*/, _b.sent()]; } }); }); }; /** * 插入 * @param commandID 命令名称 * @param objects 对象 */ MongoQueryService.prototype.insert = function (commandID, objects) { return __awaiter(this, void 0, void 0, function () { var command, insertObjects, insertResult, result; return __generator(this, function (_a) { switch (_a.label) { case 0: command = this.getCommandAndFilterName(commandID).command; insertObjects = objects.map(function (obj) { if (pao_aop_1.typeNamePropertyName in obj) { delete obj[pao_aop_1.typeNamePropertyName]; } return obj; }); return [4 /*yield*/, this.storage.insert(command.collection, insertObjects)]; case 1: insertResult = _a.sent(); result = { resultIDs: {} }; Object.keys(insertResult.insertedIds).forEach(function (key) { result.resultIDs[key] = insertResult.insertedIds[key].toString(); }); return [2 /*return*/, result]; } }); }); }; /** * 获取数量 * @param {string} commandID 命令ID * @param {{}} paramValues 参数 */ MongoQueryService.prototype.count = function (commandID, paramValues) { return __awaiter(this, void 0, void 0, function () { var _a, command, filterName, where; return __generator(this, function (_b) { switch (_b.label) { case 0: _a = this.getCommandAndFilterName(commandID), command = _a.command, filterName = _a.filterName; where = command.getCondition(filterName, paramValues); return [4 /*yield*/, this.storage.count(command.collection, where)]; case 1: return [2 /*return*/, _b.sent()]; } }); }); }; /** * 更新 * @param commandID 命令ID * @param objects 待更新对象列表 * */ MongoQueryService.prototype.update = function (commandID, objects) { return __awaiter(this, void 0, void 0, function () { var command, result; return __generator(this, function (_a) { switch (_a.label) { case 0: command = this.getCommandAndFilterName(commandID).command; return [4 /*yield*/, this.storage.update(command.collection, objects)]; case 1: result = _a.sent(); return [2 /*return*/, result]; } }); }); }; /** * 删除数据 * @param {string} commandID 命令ID * @param {Object[]} objects 插入对象集合 */ MongoQueryService.prototype.delete = function (commandID, objects) { return __awaiter(this, void 0, void 0, function () { var _a, command, primaryKeys, result; return __generator(this, function (_b) { switch (_b.label) { case 0: _a = this.getCommandAndFilterName(commandID), command = _a.command, primaryKeys = _a.primaryKeys; return [4 /*yield*/, this.storage.delete(command.collection, primaryKeys, objects)]; case 1: result = _b.sent(); return [2 /*return*/, result]; } }); }); }; MongoQueryService = __decorate([ pao_aop_1.addon('MongoQueryService', 'Mongo 数据服务', '提供Mongo数据库查询的服务'), __metadata("design:paramtypes", [MongoStorage]) ], MongoQueryService); return MongoQueryService; }(base_1.BaseService)); exports.MongoQueryService = MongoQueryService; }); //# sourceMappingURL=index.js.map