CastError: Cast to Number failed for value "asdad"at path "year"오류

4556 단어
ValidationError: Movie validation failed
    at MongooseError.ValidationError (/home/decade/code/test/node_modules/mongoose/lib/error/validation.js:22:11)
    at model.Document.invalidate (/home/decade/code/test/node_modules/mongoose/lib/document.js:1410:32)
    at model.Document.set (/home/decade/code/test/node_modules/mongoose/lib/document.js:695:10)
    at model.Document.set (/home/decade/code/test/node_modules/mongoose/lib/document.js:540:18)
    at model.Document (/home/decade/code/test/node_modules/mongoose/lib/document.js:66:10)
    at model.Model (/home/decade/code/test/node_modules/mongoose/lib/model.js:41:12)
    at new model (/home/decade/code/test/node_modules/mongoose/lib/model.js:3191:11)
    at /home/decade/code/test/app.js:166:14
    at Layer.handle [as handle_request] (/home/decade/code/test/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/decade/code/test/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/home/decade/code/test/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/decade/code/test/node_modules/express/lib/router/layer.js:95:5)
    at /home/decade/code/test/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/home/decade/code/test/node_modules/express/lib/router/index.js:330:12)
    at next (/home/decade/code/test/node_modules/express/lib/router/index.js:271:10)
    at /home/decade/code/test/node_modules/body-parser/lib/read.js:129:5
  message: 'Movie validation failed',
  name: 'ValidationError',
  errors: 
   { year: 
      { CastError: Cast to Number failed for value "asdad" at path "year"
          at MongooseError.CastError (/home/decade/code/test/node_modules/mongoose/lib/error/cast.js:19:11)
          at model.Document.set (/home/decade/code/test/node_modules/mongoose/lib/document.js:696:7)
          at model.Document.set (/home/decade/code/test/node_modules/mongoose/lib/document.js:540:18)
          at model.Document (/home/decade/code/test/node_modules/mongoose/lib/document.js:66:10)
          at model.Model (/home/decade/code/test/node_modules/mongoose/lib/model.js:41:12)
          at new model (/home/decade/code/test/node_modules/mongoose/lib/model.js:3191:11)
          at /home/decade/code/test/app.js:166:14
          at Layer.handle [as handle_request] (/home/decade/code/test/node_modules/express/lib/router/layer.js:95:5)
          at next (/home/decade/code/test/node_modules/express/lib/router/route.js:131:13)
          at Route.dispatch (/home/decade/code/test/node_modules/express/lib/router/route.js:112:3)
          at Layer.handle [as handle_request] (/home/decade/code/test/node_modules/express/lib/router/layer.js:95:5)
          at /home/decade/code/test/node_modules/express/lib/router/index.js:277:22
          at Function.process_params (/home/decade/code/test/node_modules/express/lib/router/index.js:330:12)
          at next (/home/decade/code/test/node_modules/express/lib/router/index.js:271:10)
          at /home/decade/code/test/node_modules/body-parser/lib/read.js:129:5
          at invokeCallback (/home/decade/code/test/node_modules/body-parser/node_modules/raw-body/index.js:262:16)
        message: 'Cast to Number failed for value "asdad" at path "year"',
        name: 'CastError',
        kind: 'Number',
        value: 'asdad',
        path: 'year',
        reason: [Object] } } }
/home/decade/code/test/app.js:180
      res.redirect('/movie/'+movie._id);
                                  ^

TypeError: Cannot read property '_id' of undefined
    at /home/decade/code/test/app.js:180:35
    at /home/decade/code/test/node_modules/mongoose/lib/document.js:1900:19
    at handleError (/home/decade/code/test/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:40:22)
    at _next (/home/decade/code/test/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:46:22)
    at fnWrapper (/home/decade/code/test/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:186:18)
    at /home/decade/code/test/node_modules/mongoose/lib/schema.js:200:17
    at /home/decade/code/test/node_modules/mongoose/node_modules/kareem/index.js:127:16
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

오류 보고 오류 원인 CastError: Cast to Number failed for value "asdad"at path "year"유형이 일치하지 않습니다. asdad는number형이 아닙니다.

좋은 웹페이지 즐겨찾기