亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

添加電影的時候報了一個錯誤,我有點懵逼,還請小伙伴看看,這到底是什么錯

{ [CastError: Cast to ObjectId failed for value "" at path "_id" for model "Movie"]

? message: 'Cast to ObjectId failed for value "" at path "_id" for model "Movie"',

? name: 'CastError',

? stringValue: '""',

? kind: 'ObjectId',

? value: '',

? path: '_id',

? reason: undefined,

? model:

? ?{ [Function: model]

? ? ?hooks: Kareem { _pres: {}, _posts: {} },

? ? ?base:

? ? ? Mongoose {

? ? ? ? connections: [Object],

? ? ? ? models: [Object],

? ? ? ? modelSchemas: [Object],

? ? ? ? options: [Object] },

? ? ?modelName: 'Movie',

? ? ?model: [Function: model],

? ? ?db:

? ? ? NativeConnection {

? ? ? ? base: [Object],

? ? ? ? collections: [Object],

? ? ? ? models: [Object],

? ? ? ? config: [Object],

? ? ? ? replica: false,

? ? ? ? hosts: null,

? ? ? ? host: null,

? ? ? ? port: null,

? ? ? ? user: null,

? ? ? ? pass: null,

? ? ? ? name: null,

? ? ? ? options: null,

? ? ? ? otherDbs: [],

? ? ? ? _readyState: 0,

? ? ? ? _closeCalled: false,

? ? ? ? _hasOpened: false,

? ? ? ? _listening: false },

? ? ?discriminators: undefined,

? ? ?fetch: [Function],

? ? ?findById: [Function],

? ? ?_events: { init: [Function], save: [Function] },

? ? ?_eventsCount: 2,

? ? ?schema:

? ? ? Schema {

? ? ? ? obj: [Object],

? ? ? ? paths: [Object],

? ? ? ? aliases: {},

? ? ? ? subpaths: {},

? ? ? ? virtuals: [Object],

? ? ? ? singleNestedPaths: {},

? ? ? ? nested: [Object],

? ? ? ? inherits: {},

? ? ? ? callQueue: [Object],

? ? ? ? _indexes: [],

? ? ? ? methods: {},

? ? ? ? statics: [Object],

? ? ? ? tree: [Object],

? ? ? ? query: {},

? ? ? ? childSchemas: [],

? ? ? ? plugins: [Object],

? ? ? ? s: [Object],

? ? ? ? options: [Object],

? ? ? ? '$globalPluginsApplied': true },

? ? ?collection:

? ? ? NativeCollection {

? ? ? ? collection: null,

? ? ? ? opts: [Object],

? ? ? ? name: 'movies',

? ? ? ? collectionName: 'movies',

? ? ? ? conn: [Object],

? ? ? ? queue: [],

? ? ? ? buffer: true,

? ? ? ? emitter: [Object] },

? ? ?Query: { [Function] base: [Object] },

? ? ?'$__insertMany': [Function],

? ? ?insertMany: [Function] } }

events.js:141

? ? ? throw er; // Unhandled 'error' event

? ? ? ^


TypeError: Cannot read property 'save' of undefined

? ? at D:\wabstrom\film\app.js:94:19

? ? at D:\wabstrom\film\node_modules\mongoose\lib\query.js:2843:9

? ? at tryCatcher (D:\wabstrom\film\node_modules\bluebird\js\main\util.js:26:23)

? ? at Promise._settlePromiseFromHandler (D:\wabstrom\film\node_modules\bluebird\js\main\promise.js:507:31)

? ? at Promise._settlePromiseAt (D:\wabstrom\film\node_modules\bluebird\js\main\promise.js:581:18)

? ? at Promise._settlePromises (D:\wabstrom\film\node_modules\bluebird\js\main\promise.js:697:14)

? ? at Async._drainQueue (D:\wabstrom\film\node_modules\bluebird\js\main\async.js:123:16)

? ? at Async._drainQueues (D:\wabstrom\film\node_modules\bluebird\js\main\async.js:133:10)

? ? at Immediate.Async.drainQueues [as _onImmediate] (D:\wabstrom\film\node_modules\bluebird\js\main\async.js:15:14)

? ? at processImmediate [as _immediateCallback] (timers.js:383:17)


正在回答

2 回答

我之前也報這個錯,我把movieObj改好以后就沒了

var movieObj = req.req.body.movie

我自己改了是這樣才能得到movieObj

0 回復 有任何疑惑可以回復我~

TypeError: Cannot read property 'save' of undefined,意思是無save屬性,看看你要存入的模塊實例的原型是是否model

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
node+mongodb 建站攻略(一期)
  • 參與學習       91828    人
  • 解答問題       921    個

帶你完整實現一個從前端到后端的項目,初中級前端開發工程師必學課程

進入課程

添加電影的時候報了一個錯誤,我有點懵逼,還請小伙伴看看,這到底是什么錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號