Skip to content

Commit

Permalink
Merge pull request #53 from synatic/develop
Browse files Browse the repository at this point in the history
Fixing typo and deprecating old version
  • Loading branch information
thiren authored Jun 18, 2024
2 parents c3b7ede + 4f6f76e commit ff6474a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: "Build"

on:
push:
branches: [master, develop]
pull_request:
workflow_dispatch:
inputs:
reason:
Expand All @@ -19,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
services:
mongo:
image: mongo:6.0
image: mongo:7.0
options: >-
--health-cmd mongosh
--health-interval 10s
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ci-codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: "CodeQL Analysis"

on:
push:
branches: [master, develop]
pull_request:
# The branches below must be a subset of the branches above
branches: [master, develop]
workflow_dispatch:
inputs:
reason:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
services:
mongo:
image: mongo:6.0
image: mongo:7.0
options: >-
--health-cmd mongosh
--health-interval 10s
Expand Down
62 changes: 34 additions & 28 deletions lib/Collection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable valid-jsdoc */

const {callbackify} = require('node:util');
const $moment = require('moment');
const $check = require('check-types');
const MongoQuery = require('./MongoQuery.js');
Expand Down Expand Up @@ -70,16 +71,19 @@ class Collection {
}

const filter = query.parsedQuery.query || {};
this._collection
.countDocuments(filter, options)
.then((count) => {
if (!count) {
return callback(null, 0);
}

return callback(null, count);
})
.catch(callback);
callbackify(() => {
return this._collection.countDocuments(filter, options);
})((err, count) => {
if (err) {
return callback(err);
}

if (!count) {
return callback(null, 0);
}

return callback(null, count);
});
}

/**
Expand Down Expand Up @@ -143,19 +147,18 @@ class Collection {
return callback(new Error('Invalid query object'));
}
try {
const cursor = this.queryAsCursor(query, options);

cursor
.toArray()
.then((results) => {
if (!results) {
return callback(null, []);
}
return callback(null, results);
})
.catch((err) => {
callbackify(() => {
return this.queryAsCursor(query, options).toArray();
})((err, results) => {
if (err) {
return callback(err);
});
}

if (!results) {
return callback(null, []);
}
return callback(null, results);
});
} catch (exp) {
return callback(exp);
}
Expand Down Expand Up @@ -225,12 +228,15 @@ class Collection {
update.$inc[dayPath + '.' + increment.field] = increment.value;
update.$inc[hourPath + '.' + increment.field] = increment.value;
}
this._collection
.updateOne(options.query, update)
.then((result) => {
return callback(null, result);
})
.catch(callback);
callbackify(() => {
return this._collection.updateOne(options.query, update);
})((err, result) => {
if (err) {
return callback(err);
}

return callback(null, result);
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synatic/mongo-magic",
"version": "2.2.0",
"version": "2.3.0",
"description": "Synatic utility classes for interacting with MongoDB",
"main": "index.js",
"files": [
Expand Down

0 comments on commit ff6474a

Please sign in to comment.