Commit 0cfce6d0 authored by huanglu's avatar huanglu

feat: 去除mongo

parent 2ad1654c
import { Application } from 'egg';
module.exports = (app: Application) => {
const mongoose = app.mongoose;
const Schema = mongoose.Schema;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
module.exports = (_app: Application) => {
// const mongoose = app.mongoose;
// const Schema = mongoose.Schema;
const ChatRoomSchema = new Schema({
roomId: { type: String },
roomName: { type: String },
ids: { type: Array },
});
// const ChatRoomSchema = new Schema({
// roomId: { type: String },
// roomName: { type: String },
// ids: { type: Array },
// });
ChatRoomSchema.pre('save', async function(next) {
app.model.GCounter.findByIdAndUpdate('chatRoomId', { $inc: { roomId: 1 } as any }, { new: true, upsert: true }, (error, counter) => {
if (error) return next(error);
(this as any).roomId = (counter as any).roomId;
next();
});
});
// ChatRoomSchema.pre('save', async function(next) {
// app.model.GCounter.findByIdAndUpdate('chatRoomId', { $inc: { roomId: 1 } as any }, { new: true, upsert: true }, (error, counter) => {
// if (error) return next(error);
// (this as any).roomId = (counter as any).roomId;
// next();
// });
// });
return mongoose.model('ChatRoom', ChatRoomSchema);
// return mongoose.model('ChatRoom', ChatRoomSchema);
};
import { Application } from 'egg';
module.exports = (app: Application) => {
const mongoose = app.mongoose;
const Schema = mongoose.Schema;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
module.exports = (_app: Application) => {
// const mongoose = app.mongoose;
// const Schema = mongoose.Schema;
const ChatUserSchema = new Schema({
name: { type: String },
username: { type: String },
avator: { type: String },
password: { type: String },
token: { type: String },
userId: { type: Number },
});
// const ChatUserSchema = new Schema({
// name: { type: String },
// username: { type: String },
// avator: { type: String },
// password: { type: String },
// token: { type: String },
// userId: { type: Number },
// });
const userModel = mongoose.model('ChatUser', ChatUserSchema);
return userModel;
// const userModel = mongoose.model('ChatUser', ChatUserSchema);
// return userModel;
};
import { Application } from 'egg';
module.exports = (app: Application) => {
const mongoose = app.mongoose;
const Schema = mongoose.Schema;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
module.exports = (_app: Application) => {
// const mongoose = app.mongoose;
// const Schema = mongoose.Schema;
const RoomCounterSchema = new Schema({
_id: { type: String, default: 'chatRoomId' },
roomId: { type: Number },
userId: { type: Number, default: 100000 },
});
// const RoomCounterSchema = new Schema({
// _id: { type: String, default: 'chatRoomId' },
// roomId: { type: Number },
// userId: { type: Number, default: 100000 },
// });
return mongoose.model('GCounter', RoomCounterSchema);
// return mongoose.model('GCounter', RoomCounterSchema);
};
......@@ -9,7 +9,7 @@
},
"scripts": {
"start": "npm run tsc && egg-scripts start --daemon --sticky",
"stop": "egg-scripts stop --title=egg-server-geek-egg",
"stop": "egg-scripts stop",
"dev": "egg-bin dev --sticky",
"debug": "egg-bin debug",
"test-local": "egg-bin test",
......
......@@ -18,7 +18,6 @@ import 'egg-view-nunjucks';
import 'egg-socket.io';
import 'egg-redis';
import 'egg-cors';
import 'egg-mongoose';
import 'egg-jwt';
import { EggPluginItem } from 'egg';
declare module 'egg' {
......@@ -39,7 +38,6 @@ declare module 'egg' {
io?: EggPluginItem;
redis?: EggPluginItem;
cors?: EggPluginItem;
mongoose?: EggPluginItem;
jwt?: EggPluginItem;
}
}
\ No newline at end of file
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