Comments (5)
can you provide the exact error message?
from express-routes-mapper.
Sure
remove-provisional
is interpreted as :userId, which is expected but the error could inform what's wrong
{ CastError: Cast to ObjectId failed for value "remove-provisional" at path "_id" for model "User"
at new CastError (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/error/cast.js:27:11)
at ObjectId.cast (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schema/objectid.js:158:13)
at ObjectId.SchemaType.applySetters (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schematype.js:724:12)
at ObjectId.SchemaType._castForQuery (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schematype.js:1095:15)
at ObjectId.castForQuery (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schema/objectid.js:198:15)
at ObjectId.SchemaType.castForQueryWrapper (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schematype.js:1064:15)
at cast (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/cast.js:300:32)
at model.Query.Query.cast (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/query.js:3216:12)
at model.Query.Query._castConditions (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/query.js:1286:10)
at model.Query.Query._findOne (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/query.js:1502:8)
at process.nextTick (/Users/Fabi/Sites/node-project-boilerplate/node_modules/kareem/index.js:315:33)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
message: 'Cast to ObjectId failed for value "remove-provisional" at path"_id" for model "User"',
name: 'CastError',
stringValue: '"remove-provisional"',
kind: 'ObjectId',
value: 'remove-provisional',
path: '_id',
reason: undefined,
model:
{ [Function: model]
hooks: Kareem { _pres: [Object], _posts: [Object] },
base:
Mongoose {
connections: [Array],
models: [Object],
modelSchemas: [Object],
options: [Object],
_pluralize: [Function: pluralize],
plugins: [Array] },
modelName: 'User',
model: [Function: model],
db:
NativeConnection {
base: [Object],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
options: null,
otherDbs: [],
relatedDbs: {},
states: [Object],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
_connectionOptions: [Object],
client: [Object],
name: 'projectName',
'$initialConnection': [Object],
db: [Object] },
discriminators: undefined,
'$appliedMethods': true,
'$appliedHooks': true,
schema:
Schema {
obj: [Object],
paths: [Object],
aliases: {},
subpaths: {},
virtuals: [Object],
singleNestedPaths: {},
nested: [Object],
inherits: {},
callQueue: [],
_indexes: [],
methods: [Object],
statics: {},
tree: [Object],
query: {},
childSchemas: [],
plugins: [Array],
s: [Object],
_userProvidedOptions: [Object],
options: [Object],
'$globalPluginsApplied': true,
_requiredpaths: [],
_indexedpaths: [Array] },
collection:
NativeCollection {
collection: [Object],
opts: [Object],
name: 'users',
collectionName: 'users',
conn: [Object],
queue: [],
buffer: false,
emitter: [Object] },
Query: { [Function] base: [Object] },
'$__insertMany': [Function],
'$init': Promise { [Circular], catch: [Function] } } }
from express-routes-mapper.
But this is a error message from mongoose. So there is nothing that can be done here. Or what do you mean?
from express-routes-mapper.
Well this error is thrown when mongoose tries to cast remove-provisional
to ObjectId
Maybe it's possible to catch that error and suggest what the problem could be
Or throw an error when a route /model/action
is found after a /model/:modelId
route
from express-routes-mapper.
But we cannot implement error messages for another library... if message: 'Cast to ObjectId failed for value "remove-provisional" at path"_id" for model "User"',
has too less information, that should be added in mongoose.
from express-routes-mapper.
Related Issues (13)
- Security vulnerability: one router for public and private routes
- Execute middlewares before executing endpoint's method HOT 16
- update babel to version 7 HOT 3
- Problem with routes HOT 1
- mapRoutes is not a function. HOT 1
- controller as class: this is undefined! HOT 5
- Linting HOT 2
- TypeError: handler is not a constructor HOT 1
- TypeError: handler is not a constructor HOT 5
- New version of core-js HOT 1
- TypeError: handler is not a constructor
- Naming convention for controllers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-routes-mapper.