Skip to content

Commit

Permalink
Updated build and version.
Browse files Browse the repository at this point in the history
  • Loading branch information
travist committed Aug 27, 2021
1 parent c214fbf commit 8321b8b
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 430 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.vscode
node_modules
.log
.nyc_output
Expand Down
12 changes: 8 additions & 4 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## v2.4.0
### Changed
- Upgrade debug@4.3.2, coveralls@3.1.1, supertest@6.1.6, fast-json-patch@3.1.0, eslint@7.32.0, mongodb@4.1.1, mocha@9.1.0, mongoose@6.0.2

## v2.3.4
### Changed
- Upgrade dependencies.
Expand Down Expand Up @@ -61,7 +65,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The resourcejs middleware paths to be able to be processed outside of Express.

### Changed
- Upgrade mocha@7.1.0
- Upgrade mocha@7.1.0

## v2.0.0
### Changed
Expand All @@ -71,7 +75,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## v1.39.0
### Changed
- Upgrade mongoose@5.8.11, mongodb@3.5.3, mocha@7.0.1
- Upgrade mongoose@5.8.11, mongodb@3.5.3, mocha@7.0.1

## v1.38.2
### Fixed
Expand All @@ -87,7 +91,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## v1.38.0
### Fixed
- Issue where the ObjectId object is not defined in Swagger.js.

### Changed
- Upgraded mongodb@3.4.0, mongoose@5.8.0

Expand Down Expand Up @@ -131,7 +135,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## v1.25.1
### Changed
- Upgraded mongodb@3.1.3, mongoose@5.2.8, eslint@5.3.0
- Upgraded mongodb@3.1.3, mongoose@5.2.8, eslint@5.3.0

## v1.25.0
### Changed
Expand Down
24 changes: 19 additions & 5 deletions Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ class Resource {
next();
}

static ObjectId(id) {
try {
return (new mongodb.ObjectId(id));
}
catch (e) {
return id;
}
}

/**
* Sets the response that needs to be made and calls the next middleware for
* execution.
Expand Down Expand Up @@ -386,13 +395,13 @@ class Resource {
options.convertIds &&
name.match(options.convertIds) &&
(typeof value === 'string') &&
(mongodb.ObjectID.isValid(value))
(mongodb.ObjectId.isValid(value))
) {
try {
value = new mongodb.ObjectID(value);
value = Resource.ObjectId(value);
}
catch (err) {
console.warn(`Invalid ObjectID: ${value}`);
console.warn(`Invalid ObjectId: ${value}`);
}
}

Expand Down Expand Up @@ -581,9 +590,14 @@ class Resource {
}

// Get the query object.
const countQuery = req.countQuery || req.modelQuery || req.model || this.model;
let countQuery = req.countQuery || req.modelQuery || req.model || this.model;
const query = req.modelQuery || req.model || this.model;

// Make sure to clone the count query if it is available.
if (typeof countQuery.clone === 'function') {
countQuery = countQuery.clone();
}

// Get the find query.
const findQuery = this.getFindQuery(req, null, query._conditions);

Expand Down Expand Up @@ -839,7 +853,7 @@ class Resource {
const { __v, ...update} = req.body;
const query = req.modelQuery || req.model || this.model;

query.findOne({ _id: req.params[`${this.name}Id`] }, (err, item) => {
query.findOne({ _id: Resource.ObjectId(req.params[`${this.name}Id`]) }, (err, item) => {
if (err) {
debug.put(err);
return Resource.setResponse(res, { status: 400, error: err }, next);
Expand Down

0 comments on commit 8321b8b

Please sign in to comment.