Revert "Revert "feat(mongoose): upgrade mongoose to 5.0.17 to support Schema.Types.Decimal128""

This reverts commit 00d7d53725.
This commit is contained in:
OldHawk
2018-05-07 10:49:28 +08:00
parent 00d7d53725
commit ebcf5d2637
8 changed files with 23 additions and 21 deletions

View File

@@ -19,13 +19,13 @@ function seedDB() {
}
module.exports.init = function init(callback) {
mongooseService.connect(function (db) {
mongooseService.connect(function (mongooseConn) {
// Initialize Models
mongooseService.loadModels(seedDB);
// Initialize express
var app = express.init(db);
if (callback) callback(app, db, config);
var app = express.init(mongooseConn);
if (callback) callback(app, mongooseConn, config);
});
};
@@ -33,7 +33,7 @@ module.exports.init = function init(callback) {
module.exports.start = function start(callback) {
var _this = this;
_this.init(function (app, db, config) {
_this.init(function (app, mongooseConn, config) {
// Start the app by listening on <port> at <host>
app.listen(config.port, config.host, function () {
@@ -55,7 +55,7 @@ module.exports.start = function start(callback) {
console.log(chalk.green('IRC announce: disabled'));
logger.info('--');
if (callback) callback(app, db, config);
if (callback) callback(app, mongooseConn, config);
});
});

View File

@@ -118,7 +118,7 @@ module.exports.initViewEngine = function (app) {
/**
* Configure Express session
*/
module.exports.initSession = function (app, db) {
module.exports.initSession = function (app, mongooseConn) {
// Express MongoDB session storage
app.use(session({
saveUninitialized: true,
@@ -131,7 +131,8 @@ module.exports.initSession = function (app, db) {
},
name: config.sessionKey,
store: new MongoStore({
db: db,
db: mongooseConn.db,
mongooseConnection: mongooseConn.connection,
collection: config.sessionCollection
})
}));
@@ -222,9 +223,9 @@ module.exports.initErrorRoutes = function (app) {
/**
* Configure Socket.io
*/
module.exports.configureSocketIO = function (app, db) {
module.exports.configureSocketIO = function (app, mongooseConn) {
// Load the Socket.io configuration
var server = require('./socket.io')(app, db);
var server = require('./socket.io')(app, mongooseConn);
// Return server object
return server;
@@ -250,7 +251,7 @@ module.exports.initCronJob = function (app) {
/**
* Initialize the Express application
*/
module.exports.init = function (db) {
module.exports.init = function (mongooseConn) {
// Initialize express app
var app = express();
@@ -273,7 +274,7 @@ module.exports.init = function (db) {
this.initModulesClientRoutes(app);
// Initialize Express session
this.initSession(app, db);
this.initSession(app, mongooseConn);
// Initialize Modules configuration
this.initModulesConfiguration(app);
@@ -295,7 +296,7 @@ module.exports.init = function (db) {
this.initCronJob(app);
// Configure Socket.io
app = this.configureSocketIO(app, db);
app = this.configureSocketIO(app, mongooseConn);
return app;
};

View File

@@ -23,7 +23,7 @@ module.exports.loadModels = function (callback) {
module.exports.connect = function (callback) {
mongoose.Promise = config.db.promise;
var options = _.merge(config.db.options || {}, { useMongoClient: true });
var options = _.merge(config.db.options || {});
mongoose
.connect(config.db.uri, options)
@@ -32,7 +32,7 @@ module.exports.connect = function (callback) {
mongoose.set('debug', config.db.debug);
// Call callback FN
if (callback) callback(connection.db);
if (callback) callback(connection);
})
.catch(function (err) {
console.error(chalk.red('Could not connect to MongoDB!'));

View File

@@ -15,7 +15,7 @@ var config = require('../config'),
MongoStore = require('connect-mongo')(session);
// Define the Socket.io configuration method
module.exports = function (app, db) {
module.exports = function (app, mongooseConn) {
var server;
if (config.secure && config.secure.ssl === true) {
// Load SSL key and certificate
@@ -75,7 +75,8 @@ module.exports = function (app, db) {
// Create a MongoDB storage object
var mongoStore = new MongoStore({
db: db,
db: mongooseConn.db,
mongooseConnection: mongooseConn.connection,
collection: config.sessionCollection
});

View File

@@ -51,7 +51,7 @@ var AnnounceLogSchema = new Schema({
default: 0
},
write_score: {
type: Number,
type: Schema.Types.Decimal128,
default: 0
},
isVip: {

View File

@@ -35,7 +35,7 @@ var UserDaysLogSchema = new Schema({
default: 0
},
score: {
type: Number,
type: Schema.Types.Decimal128,
default: 0
},
createdAt: {

View File

@@ -31,7 +31,7 @@ var UserMonthsLogSchema = new Schema({
default: 0
},
score: {
type: Number,
type: Schema.Types.Decimal128,
default: 0
},
createdAt: {

View File

@@ -49,7 +49,7 @@
"cloudflare-express": "^1.0.1",
"compression": "~1.7.0",
"connect-flash": "~0.1.1",
"connect-mongo": "~2.0.0",
"connect-mongo": "^2.0.1",
"cookie-parser": "~1.4.1",
"cron": "^1.2.1",
"del": "~3.0.0",
@@ -90,7 +90,7 @@
"mocha": "~3.4.2",
"moment": "^2.18.1",
"mongodb-backup": "^1.6.9",
"mongoose": "^4.13.12",
"mongoose": "^5.0.17",
"morgan": "~1.8.1",
"moviedb": "^0.2.10",
"multer": "~1.3.0",