- Moved
@types/mongoose
as a dependency instead of devDependency
- Security update: mongoose dependency
- Bugfix : in some cases, the mongoose
save()
was not awaited, hense leading to errors if you updated the entity inpreSend
. You should update to this version as soone as possible.
Restgoose.onError()
: changed API so it can return aRestError
and be async. You can easily migrate by addingasync
to your handler implementation and return null at the end.@rest
: AddonError()
in the decorator. It has precedence overRestgoose.onError()
: if it is set and returns something butnull
,Restgoose.onError()
won't be called.
Allow one() to use a filter (GET ?q=...
), the same way all() does.
Broken, use 1.1.4
Add onError()
global handler.
This will be trigerred if an unknown error is thrown, i.e. not a RestError
, nor a ValidationError
.
Basically when the server would return 500 by default.
Add support for access to the previous value in preSend
and save
middlewares (when available).
BREAKING CHANGE
Unified middlewares preFetch
, postFetch
, preSave
, preSend
, persist
.
Now, all middlewares can be written as function <T extends RestgooseModel>(req: Request, entity: T): Promise<T>
.
preFetch
middlewares should now return null
instead of true
.
This version only updates development tools. No need to update.
- Updated dependencies : codecov, mocha & tslint.
BREAKING CHANGE restgoose does not use typegoose anymore. A subset of it has been ported inside restgoose for better stability.
Changes:
- Removed typegoose
- Aligned create() on update(), so a fetchOrCreate pattern is easier with create()
- parseQuery now converts
${oid: 'xxxx'}
toObjectId('xxxx')
instead of{$in: [ ObjectId('xxxx'), 'xxxx' ]}
Features:
- Add support for submodel one()
Features:
- BREAKING CHANGE getModel(): reordered method arguments and allow using the default mongoose connection.
Features:
- Added a
restgoose
field inreq
for typical use cases (projection, pagination...) - Automatic parsing of the query string
q
Bugfixes:
- createWithin - Ensure that the containing field is defined before pushing in it
Bugfixes:
- Fixed embedded submodels with a
ref
field wrongly considered as referenced.
Features:
- Support for embedded submodels along with referenced ones
- Restgoose.initialize() - added argument to initialize a subset of models
Features:
- Updates dependencies
- fetch:
- add
modelType
in function signature
- add
- add
Restgoose.sendOne()
Bugfixes:
- Fixed error handling on CastError
Features:
- Support for multiple database through the
getConnection
hook - Add schemaOptions in the
@rest
decorator - Allow non
@rest
models to use getModel() - getModel()
- Add newModel.init()
- Add newModel.ensureIndexes()
- Updated minimal dependencies : typegoose ^5.4.0
- preSave:
- changed function signature : inverted prev and current
- add
oldEntity
in function signature
Bugfixes:
- Fixed error when no
methods
are defined in @rest - Add
postFetch
increate()
endpoint