Mongoose 5 (#9870)

* mongoose 5: remove unused autoinc, remove promise option (it uses native promises now)

* remove mongodb package

* remove mongoskin

* migrate migration away from mongoskin

* fix mongoose hooks

* fix _updateUserWithRetries

* try without next

* remove init

* update sinon

* fix some integration tests

* fix remaining tests

* fix error message

* fix error message

* fix error message

* another fix

* fix mongoose options

* remove greenkeeper exception
This commit is contained in:
Matteo Pagliazzi
2018-03-09 13:13:58 -08:00
committed by Sabe Jones
parent f9a47b1420
commit 1332fd68b0
6 changed files with 3506 additions and 2190 deletions

View File

@@ -26,7 +26,6 @@ let improveRepl = (context) => {
const mongooseOptions = !isProd ? {} : { const mongooseOptions = !isProd ? {} : {
keepAlive: 1, keepAlive: 1,
connectTimeoutMS: 30000, connectTimeoutMS: 30000,
useMongoClient: true,
}; };
mongoose.connect( mongoose.connect(
nconf.get('NODE_DB_URI'), nconf.get('NODE_DB_URI'),

5663
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,11 +3,6 @@
"description": "A habit tracker app which treats your goals like a Role Playing Game.", "description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "4.29.6", "version": "4.29.6",
"main": "./website/server/index.js", "main": "./website/server/index.js",
"greenkeeper": {
"ignore": [
"mongoose"
]
},
"dependencies": { "dependencies": {
"@slack/client": "^3.8.1", "@slack/client": "^3.8.1",
"accepts": "^1.3.2", "accepts": "^1.3.2",
@@ -66,8 +61,8 @@
"merge-stream": "^1.0.0", "merge-stream": "^1.0.0",
"method-override": "^2.3.5", "method-override": "^2.3.5",
"moment": "^2.13.0", "moment": "^2.13.0",
"mongoose": "^5.0.3",
"moment-recur": "^1.0.7", "moment-recur": "^1.0.7",
"mongoose": "^4.13.11",
"morgan": "^1.7.0", "morgan": "^1.7.0",
"nconf": "^0.10.0", "nconf": "^0.10.0",
"node-gcm": "^0.14.4", "node-gcm": "^0.14.4",

View File

@@ -1,20 +1,15 @@
import nconf from 'nconf'; import nconf from 'nconf';
import logger from './logger'; import logger from './logger';
import mongoose from 'mongoose'; import mongoose from 'mongoose';
import Bluebird from 'bluebird';
const IS_PROD = nconf.get('IS_PROD'); const IS_PROD = nconf.get('IS_PROD');
const MAINTENANCE_MODE = nconf.get('MAINTENANCE_MODE'); const MAINTENANCE_MODE = nconf.get('MAINTENANCE_MODE');
// Use Q promises instead of mpromise in mongoose
mongoose.Promise = Bluebird;
// Do not connect to MongoDB when in maintenance mode // Do not connect to MongoDB when in maintenance mode
if (MAINTENANCE_MODE !== 'true') { if (MAINTENANCE_MODE !== 'true') {
const mongooseOptions = !IS_PROD ? {} : { const mongooseOptions = !IS_PROD ? {} : {
keepAlive: 120, keepAlive: 120,
connectTimeoutMS: 30000, connectTimeoutMS: 30000,
useMongoClient: true,
}; };
const NODE_DB_URI = nconf.get('IS_TEST') ? nconf.get('TEST_DB_URI') : nconf.get('NODE_DB_URI'); const NODE_DB_URI = nconf.get('IS_TEST') ? nconf.get('TEST_DB_URI') : nconf.get('NODE_DB_URI');

View File

@@ -50,7 +50,7 @@ schema.plugin(baseModel, {
timestamps: true, timestamps: true,
}); });
schema.pre('init', function ensureSummaryIsFetched (next, chal) { schema.pre('init', function ensureSummaryIsFetched (chal) {
// The Vue website makes the summary be mandatory for all new challenges, but the // The Vue website makes the summary be mandatory for all new challenges, but the
// Angular website did not, and the API does not yet for backwards-compatibilty. // Angular website did not, and the API does not yet for backwards-compatibilty.
// When any challenge without a summary is fetched from the database, this code // When any challenge without a summary is fetched from the database, this code
@@ -59,7 +59,6 @@ schema.pre('init', function ensureSummaryIsFetched (next, chal) {
if (!chal.summary) { if (!chal.summary) {
chal.summary = chal.name ? chal.name.substring(0, MAX_SUMMARY_SIZE_FOR_CHALLENGES) : ' '; chal.summary = chal.name ? chal.name.substring(0, MAX_SUMMARY_SIZE_FOR_CHALLENGES) : ' ';
} }
next();
}); });
// A list of additional fields that cannot be updated (but can be set on creation) // A list of additional fields that cannot be updated (but can be set on creation)

View File

@@ -140,7 +140,7 @@ schema.plugin(baseModel, {
}, },
}); });
schema.pre('init', function ensureSummaryIsFetched (next, group) { schema.pre('init', function ensureSummaryIsFetched (group) {
// The Vue website makes the summary be mandatory for all new groups, but the // The Vue website makes the summary be mandatory for all new groups, but the
// Angular website did not, and the API does not yet for backwards-compatibilty. // Angular website did not, and the API does not yet for backwards-compatibilty.
// When any guild without a summary is fetched from the database, this code // When any guild without a summary is fetched from the database, this code
@@ -151,7 +151,6 @@ schema.pre('init', function ensureSummaryIsFetched (next, group) {
if (!group.summary) { if (!group.summary) {
group.summary = group.name ? group.name.substring(0, MAX_SUMMARY_SIZE_FOR_GUILDS) : ' '; group.summary = group.name ? group.name.substring(0, MAX_SUMMARY_SIZE_FOR_GUILDS) : ' ';
} }
next();
}); });
// A list of additional fields that cannot be updated (but can be set on creation) // A list of additional fields that cannot be updated (but can be set on creation)