cgserver 13.0.4 → 13.0.6

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.
@@ -83,7 +83,7 @@ class MongoBaseService {
83
83
  if (!this.model) {
84
84
  throw new Error("Model is not defined");
85
85
  }
86
- return await this.model.findById(id, projection, options);
86
+ return await this.model.findById(id, projection, options).lean();
87
87
  }
88
88
  async create(doc) {
89
89
  if (!this.model) {
@@ -149,7 +149,7 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
149
149
  }
150
150
  if (force_user) {
151
151
  let userser = this.userService;
152
- let user = await userser.findOne({ account_id: account.id });
152
+ let user = await userser.findOne({ account_id: account._id.toString() });
153
153
  if (!user) {
154
154
  switch (from) {
155
155
  case ini_1.EAccountFrom.QQ:
@@ -193,9 +193,9 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
193
193
  };
194
194
  }
195
195
  }
196
- let user = await userser.add(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);
196
+ let user = await userser.add(account._id.toString(), extra_info.nickname, extra_info.sex, extra_info.logo);
197
197
  if (!user) {
198
- this.deleteOne({ id: account.id });
198
+ this.deleteOne({ id: account._id.toString() });
199
199
  rs.errcode = _error_1.EErrorCode.User_Create_Failed;
200
200
  return rs;
201
201
  }
@@ -206,13 +206,13 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
206
206
  {
207
207
  let user = null;
208
208
  if (extra_info) {
209
- user = await userser.add(account.id, extra_info.nickname, extra_info.sex, extra_info.logo);
209
+ user = await userser.add(account._id.toString(), extra_info.nickname, extra_info.sex, extra_info.logo);
210
210
  }
211
211
  else {
212
- user = await userser.add(account.id);
212
+ user = await userser.add(account._id.toString());
213
213
  }
214
214
  if (!user) {
215
- this.deleteOne({ id: account.id });
215
+ this.deleteOne({ _id: account._id });
216
216
  rs.errcode = _error_1.EErrorCode.User_Create_Failed;
217
217
  return rs;
218
218
  }
@@ -229,7 +229,7 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
229
229
  }
230
230
  account.login_time = new Date();
231
231
  account.login_ip = ip;
232
- await account.save();
232
+ this.updateOne({ _id: account._id }, { $set: { login_time: account.login_time, login_ip: account.login_ip } });
233
233
  rs.account = account;
234
234
  return rs;
235
235
  }
@@ -1,6 +1,6 @@
1
- import mongoose, { Document, FilterQuery, UpdateQuery, Types, MongooseQueryOptions } from 'mongoose';
1
+ import mongoose, { FilterQuery, UpdateQuery, Types, MongooseQueryOptions } from 'mongoose';
2
2
  import { Errcode } from '../../Config/_error_';
3
- export declare class MongoBaseService<T extends Document> {
3
+ export declare class MongoBaseService<T> {
4
4
  protected _model: mongoose.Model<T>;
5
5
  protected _schema: mongoose.Schema<T>;
6
6
  protected _collection_name: string;
@@ -1,9 +1,10 @@
1
- import mongoose from 'mongoose';
1
+ import mongoose, { Types } from 'mongoose';
2
2
  import { Errcode } from '../Config/_error_';
3
3
  import { MongoBaseService } from '../Database/Mongo/MongoBaseService';
4
4
  import { EAccountFrom, EAccountState } from './ini';
5
5
  import { IMongoUserModel, MongoUserService } from './MongoUserService';
6
- export interface IMongoAccountModel extends mongoose.Document {
6
+ export interface IMongoAccountModel {
7
+ _id: Types.ObjectId;
7
8
  phone: string;
8
9
  email: string;
9
10
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "13.0.4",
3
+ "version": "13.0.6",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",