Commit 408260f6 authored by qinhaitao's avatar qinhaitao

perf: ️ 增加mongo代码提示

parent 43b8148d
/** @format */
interface Iconfig {
export interface Iconfig {
generateVipCallBackUrl(activityId?: string): string;
}
export declare const getConfig: (context: IContext<{}>) => Iconfig;
export {};
......@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
/** @format */
......
......@@ -91,11 +91,10 @@ exports.services = function (services) {
case 0:
context = args[0], _a = args[1], otherArgs = _a === void 0 ? {} : _a;
servicesInstance = services.map(function (v) { return new v(context); });
return [4 /*yield*/, initBaseInfo(context, otherArgs)
// 默认全局try catch 如果有noCatch参数则直接执行
];
return [4 /*yield*/, initBaseInfo(context, otherArgs)];
case 1:
baseInfos = _b.sent();
utils_1.logFn(context);
// 默认全局try catch 如果有noCatch参数则直接执行
if (baseInfos.noCatch) {
delete baseInfos.noCatch;
......@@ -104,7 +103,6 @@ exports.services = function (services) {
_b.label = 2;
case 2:
_b.trys.push([2, 4, , 6]);
utils_1.logFn(context);
return [4 /*yield*/, method.apply(target, [context, baseInfos, servicesInstance])];
case 3:
ret = _b.sent();
......
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/decorator/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,sCAAwC;AACxC,kCAAkE;AAClE,8BAAqC;AACrC,0CAAyC;AACzC,SAAe,YAAY,CAAC,OAA0B,EAAE,SAA2B;;;;;;oBAC3E,WAAW,GAAG,IAAI,qBAAW,CAAC,OAAO,CAAC,CAAA;yBAExC,CAAC,SAAS,CAAC,QAAQ,EAAnB,wBAAmB;o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AC,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,EAAA;;4BAAxE,GAAG,GAAG,SAAkE,CAAA;;;;4BAExE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAK,CAAC,CAAA;4BAC3B,qBAAM,sBAAc,CAAC,OAAO,EAAE,SAAS,EAAE,OAAK,CAAC,QAAQ,EAAE,EAAE,OAAK,CAAC,KAAK,CAAC,EAAA;;4BAAvE,SAAuE,CAAA;4BACvE,GAAG,GAAG,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,CAAC,CAAA;;gCAEnD,sBAAO,GAAG,EAAA;;;;SACX,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
......@@ -8,7 +8,7 @@ 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]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
......
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskService = exports.AwardsService = exports.UserService = exports.BaseService = exports.AccessService = void 0;
var access_service_1 = require("./access.service");
Object.defineProperty(exports, "AccessService", { enumerable: true, get: function () { return access_service_1.default; } });
var base_service_1 = require("./base.service");
......
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB;AACjC,+CAAuD;AAA9C,2GAAA,OAAO,OAAe;AAC/B,+CAAuD;AAA9C,2GAAA,OAAO,OAAe;AAC/B,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB;AACjC,+CAAuD;AAA9C,2GAAA,OAAO,OAAe"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB;AACjC,+CAAuD;AAA9C,2GAAA,OAAO,OAAe;AAC/B,+CAAuD;AAA9C,2GAAA,OAAO,OAAe;AAC/B,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB;AACjC,+CAAuD;AAA9C,2GAAA,OAAO,OAAe"}
\ No newline at end of file
......@@ -8,7 +8,7 @@ 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]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
......
......@@ -8,7 +8,7 @@ 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]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
......
......@@ -8,7 +8,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
// 获取商家session
......
......@@ -3,7 +3,7 @@
import online from './online'
import test from './test'
interface Iconfig {
export interface Iconfig {
generateVipCallBackUrl(activityId?: string): string
}
......
......@@ -33,6 +33,9 @@ export const services = (services: any[]) => {
let [context, otherArgs = {}] = args
const servicesInstance = services.map(v => new v(context))
const baseInfos: IControllerInfos = await initBaseInfo(context, otherArgs)
logFn(context)
// 默认全局try catch 如果有noCatch参数则直接执行
if (baseInfos.noCatch) {
delete baseInfos.noCatch
......@@ -40,7 +43,6 @@ export const services = (services: any[]) => {
}
let ret: IResult<any>
try {
logFn(context)
ret = await method.apply(target, [context, baseInfos, servicesInstance])
} catch (error) {
console.log('error', error)
......
......@@ -3,24 +3,24 @@
interface IBaseDao {
dbName: string
db: object
constructor(context: any, dbName: string)
constructor(context: any, dbName: string): any
/**
* 查询一条数据
* @param query
* @param projection
*/
findOne<T>(query: object, projection?: object): Promise<T | undefined>
findOne<T>(query: object, projection?: IFindProjection): Promise<T | undefined>
/**
* 查询多条数据
* @param query
* @param projection
*/
find<T>(query: object, projection?: object): Promise<T[]>
find<T>(query: object, projection?: IFindProjection): Promise<T[]>
/**
* 插入单条数据
* @param document
*/
insertOne(document: object): Promise<number>
insertOne<T>(document: any): Promise<number>
/**
* 插入多条数据
* @param documents 插入对象
......@@ -31,7 +31,7 @@ interface IBaseDao {
* @param query
* @param options
*/
update(query: object, options?: object): Promise<any>
update(query: object, options?: IUpdateQuery): Promise<any>
/**
* 删除多条数据
* @param filter
......@@ -42,11 +42,106 @@ interface IBaseDao {
* @param query
* @param options
*/
count(query: object, options?: object): Promise<number>
count(query: IMongoQuery, options?: object): Promise<number>
/**
* 聚合查询
* @param query
* @param options
*/
aggregate(aggregateOperation: object | any[]): Promise<any>
aggregate(pipeline: object | object[], options?: object): Promise<any>
}
interface IMongoQuery {
[params: string]: string | boolean | number | IQuerySelector
}
interface IQuerySelector {
// Comparison
$eq?: any
$gt?: any
$gte?: any
$in?: any[]
$lt?: any
$lte?: any
$ne?: any
$nin?: any[]
// Logical
$not?: any
// Element
/**
* When `true`, `$exists` matches the documents that contain the field,
* including documents where the field value is null.
*/
$exists?: boolean
$type?: any
// Evaluation
$expr?: any
$jsonSchema?: any
$mod?: any
$regex?: RegExp | string
$options?: string
// Geospatial
// TODO: define better types for geo queries
$geoIntersects?: { $geometry: object }
$geoWithin?: object
$near?: object
$nearSphere?: object
$maxDistance?: number
// Array
// TODO: define better types for $all and $elemMatch
$all?: any
$elemMatch?: any
$size?: any
// Bitwise
$bitsAllClear?: any
$bitsAllSet?: any
$bitsAnyClear?: any
$bitsAnySet?: any
}
interface IUpdateQuery {
$currentDate?: Date | { $type: 'date' | 'timestamp' }
$inc?: { [key: string]: number | undefined }
$min?: { [key: string]: number | undefined }
$max?: { [key: string]: number | undefined }
$mul?: { [key: string]: number | undefined }
$rename?: { [key: string]: string }
$set?: object
$setOnInsert?: object
$unset?: object
$addToSet?: object
$pop?: object
$pull?: object
$push?: object
$pullAll?: object
$bit?: {
[key: string]: { [key in 'and' | 'or' | 'xor']?: number }
}
}
interface IFindProjection {
projection?: {
[key: string]: number | boolean | any
}
sort?: {
[key: string]: 1 | -1
}
maxTimeMS?: number
upsert?: boolean
returnOriginal?: boolean
collation?: CollationDocument
}
interface CollationDocument {
locale: string
strength?: number
caseLevel?: boolean
caseFirst?: string
numericOrdering?: boolean
alternate?: string
maxVariable?: string
backwards?: boolean
normalization?: boolean
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment