cgserver 8.6.10 → 8.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34,8 +34,11 @@ class MongoBaseService {
|
|
|
34
34
|
let rs = await MongoManager_1.GMongoMgr.findOne(this._table, null, { id: id });
|
|
35
35
|
return rs.one;
|
|
36
36
|
}
|
|
37
|
-
async get(
|
|
38
|
-
|
|
37
|
+
async get(property, where) {
|
|
38
|
+
if (property) {
|
|
39
|
+
property = { projection: property };
|
|
40
|
+
}
|
|
41
|
+
let rs = await MongoManager_1.GMongoMgr.findOne(this._table, property, where);
|
|
39
42
|
return rs.one;
|
|
40
43
|
}
|
|
41
44
|
async countDocuments(where, options) {
|
|
@@ -43,11 +46,17 @@ class MongoBaseService {
|
|
|
43
46
|
return rs.count;
|
|
44
47
|
}
|
|
45
48
|
async gets(property, where, sort, skip = 0, limit = 0) {
|
|
49
|
+
if (property) {
|
|
50
|
+
property = { projection: property };
|
|
51
|
+
}
|
|
46
52
|
let rs = await MongoManager_1.GMongoMgr.findMany(this._table, property, where, sort, skip, limit);
|
|
47
53
|
return rs.list;
|
|
48
54
|
}
|
|
49
|
-
async getRandoms(num,
|
|
50
|
-
|
|
55
|
+
async getRandoms(num, property, where) {
|
|
56
|
+
if (property) {
|
|
57
|
+
property = { projection: property };
|
|
58
|
+
}
|
|
59
|
+
let rs = await MongoManager_1.GMongoMgr.simpleAggregate(this._table, property, where, null, num);
|
|
51
60
|
return rs.list;
|
|
52
61
|
}
|
|
53
62
|
async updateOne(model, where, upsert = false) {
|
|
@@ -17,10 +17,10 @@ export declare class MongoBaseService<T> {
|
|
|
17
17
|
* @param id
|
|
18
18
|
*/
|
|
19
19
|
getById(id: any): Promise<T>;
|
|
20
|
-
get(
|
|
20
|
+
get(property?: {}, where?: {}): Promise<T>;
|
|
21
21
|
countDocuments(where?: {}, options?: mongo.CountDocumentsOptions): Promise<number>;
|
|
22
22
|
gets(property?: {}, where?: {}, sort?: {}, skip?: number, limit?: number): Promise<T[]>;
|
|
23
|
-
getRandoms(num: number,
|
|
23
|
+
getRandoms(num: number, property?: {}, where?: {}): Promise<T[]>;
|
|
24
24
|
updateOne(model: any, where?: {}, upsert?: boolean): Promise<{
|
|
25
25
|
errcode: {
|
|
26
26
|
id: number;
|