cgserver 13.0.2 → 13.0.4
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.
|
@@ -68,28 +68,16 @@ class MongoBaseService {
|
|
|
68
68
|
if (!this.model) {
|
|
69
69
|
throw new Error("Model is not defined");
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
let one = await this.model.findOne(filter, projection, options).lean();
|
|
72
|
+
return one;
|
|
72
73
|
}
|
|
73
74
|
async find(filter, projection, options) {
|
|
74
75
|
filter = this._convertFilter(filter);
|
|
75
76
|
if (!this.model) {
|
|
76
77
|
throw new Error("Model is not defined");
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
async findMany(filter, projection, options, skip, limit) {
|
|
81
|
-
filter = this._convertFilter(filter);
|
|
82
|
-
if (!this.model) {
|
|
83
|
-
throw new Error("Model is not defined");
|
|
84
|
-
}
|
|
85
|
-
let query = this.model.find(filter, projection, options);
|
|
86
|
-
if (skip !== undefined) {
|
|
87
|
-
query = query.skip(skip);
|
|
88
|
-
}
|
|
89
|
-
if (limit !== undefined) {
|
|
90
|
-
query = query.limit(limit);
|
|
91
|
-
}
|
|
92
|
-
return await query.exec();
|
|
79
|
+
let list = await this.model.find(filter, projection, options).lean();
|
|
80
|
+
return list;
|
|
93
81
|
}
|
|
94
82
|
async findById(id, projection, options) {
|
|
95
83
|
if (!this.model) {
|
|
@@ -209,6 +197,10 @@ class MongoBaseService {
|
|
|
209
197
|
filter._id = new mongoose_1.Types.ObjectId(filter.id);
|
|
210
198
|
delete filter.id;
|
|
211
199
|
}
|
|
200
|
+
else if (filter.id) {
|
|
201
|
+
filter._id = filter.id;
|
|
202
|
+
delete filter.id;
|
|
203
|
+
}
|
|
212
204
|
return filter;
|
|
213
205
|
}
|
|
214
206
|
async getAutoIds() {
|
|
@@ -8,8 +8,7 @@ export declare class MongoBaseService<T extends Document> {
|
|
|
8
8
|
constructor(collection_name: string, schema: mongoose.Schema<T>);
|
|
9
9
|
findOne(filter?: FilterQuery<T>, projection?: any, options?: any): Promise<T | null>;
|
|
10
10
|
find(filter?: FilterQuery<T>, projection?: mongoose.ProjectionType<T>, options?: MongooseQueryOptions): Promise<T[]>;
|
|
11
|
-
|
|
12
|
-
findById(id: string | Types.ObjectId, projection?: any, options?: any): Promise<T | null>;
|
|
11
|
+
findById(id: string | Types.ObjectId, projection?: mongoose.ProjectionType<T>, options?: MongooseQueryOptions): Promise<T | null>;
|
|
13
12
|
create(doc: Partial<T>): Promise<T>;
|
|
14
13
|
insert(doc: Partial<T>): Promise<{
|
|
15
14
|
errcode: Errcode;
|