MongoDB 4.2 (#12331)

* use mongodb 4.2 in github actions

* use .countDocuments in place of .count
This commit is contained in:
Matteo Pagliazzi
2020-06-25 16:50:57 +02:00
committed by GitHub
parent 6058b3d4b4
commit a44aef3d9f
4 changed files with 9 additions and 9 deletions

View File

@@ -118,7 +118,7 @@ jobs:
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: sudo docker run --name mongo -d -p 27017:27017 mongo - run: sudo docker run --name mongo -d -p 27017:27017 mongo:4.2
- run: cp config.json.example config.json - run: cp config.json.example config.json
- name: npm install - name: npm install
run: | run: |
@@ -141,7 +141,7 @@ jobs:
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: sudo docker run --name mongo -d -p 27017:27017 mongo - run: sudo docker run --name mongo -d -p 27017:27017 mongo:4.2
- run: cp config.json.example config.json - run: cp config.json.example config.json
- name: npm install - name: npm install
run: | run: |
@@ -164,7 +164,7 @@ jobs:
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: sudo docker run --name mongo -d -p 27017:27017 mongo - run: sudo docker run --name mongo -d -p 27017:27017 mongo:4.2
- run: cp config.json.example config.json - run: cp config.json.example config.json
- name: npm install - name: npm install
run: | run: |

View File

@@ -45,7 +45,7 @@ async function fixGroupPlanMembers () {
pause(); pause();
groupPlanCount += 1; groupPlanCount += 1;
const canonicalMemberCount = await dbUsers.count( const canonicalMemberCount = await dbUsers.countDocuments(
{ {
$or: $or:
[ [

View File

@@ -24,13 +24,13 @@ async function _deleteUnfinishedTasks (groupMemberTask) {
async function _evaluateAllAssignedCompletion (masterTask) { async function _evaluateAllAssignedCompletion (masterTask) {
let completions; let completions;
if (masterTask.group.approval && masterTask.group.approval.required) { if (masterTask.group.approval && masterTask.group.approval.required) {
completions = await Tasks.Task.count({ completions = await Tasks.Task.countDocuments({
'group.taskId': masterTask._id, 'group.taskId': masterTask._id,
'group.approval.approved': true, 'group.approval.approved': true,
}).exec(); }).exec();
completions += 1; completions += 1;
} else { } else {
completions = await Tasks.Task.count({ completions = await Tasks.Task.countDocuments({
'group.taskId': masterTask._id, 'group.taskId': masterTask._id,
completed: true, completed: true,
}).exec(); }).exec();

View File

@@ -482,7 +482,7 @@ schema.statics.validateInvitations = async function getInvitationErr (invites, r
const query = {}; const query = {};
query['invitations.party.id'] = group._id; query['invitations.party.id'] = group._id;
// @TODO invitations are now stored like this: `'invitations.parties': []` // @TODO invitations are now stored like this: `'invitations.parties': []`
const groupInvites = await User.count(query).exec(); const groupInvites = await User.countDocuments(query).exec();
memberCount += groupInvites; memberCount += groupInvites;
// Counting the members that are going to be invited by email and uuids // Counting the members that are going to be invited by email and uuids
@@ -537,7 +537,7 @@ schema.methods.getMemberCount = async function getMemberCount () {
query = { 'party._id': this._id }; query = { 'party._id': this._id };
} }
return User.count(query).exec(); return User.countDocuments(query).exec();
}; };
schema.methods.sendChat = function sendChat (options = {}) { schema.methods.sendChat = function sendChat (options = {}) {
@@ -1743,7 +1743,7 @@ export const model = mongoose.model('Group', schema);
// initialize tavern if !exists (fresh installs) // initialize tavern if !exists (fresh installs)
// do not run when testing as it's handled by the tests and can easily cause a race condition // do not run when testing as it's handled by the tests and can easily cause a race condition
if (!nconf.get('IS_TEST')) { if (!nconf.get('IS_TEST')) {
model.count({ _id: TAVERN_ID }, (err, ct) => { model.countDocuments({ _id: TAVERN_ID }, (err, ct) => {
if (err) throw err; if (err) throw err;
if (ct > 0) return; if (ct > 0) return;
new model({ // eslint-disable-line new-cap new model({ // eslint-disable-line new-cap