// 用新对象里的字段替换老的字段出问题 _movie = _.extend(movie, movieObj);
ReferenceError: _ is not defined at E:\i_movie-master\app.js:108:22 修改电影出问题
ReferenceError: _ is not defined at E:\i_movie-master\app.js:108:22 修改电影出问题
2017-06-19
Cast to ObjectId failed for value "undefined" at path "_id"
$ node app.js
imooc started on port3000
(node:5188) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or
set the `useMongoClient` option if using `connect()` or `createConnection()`
(node:5188) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plu
g in your own promise library instead: http://mongoosejs.com/docs/promises.html
{ MongooseError: Cast to ObjectId failed for value "undefined" at path "_id"
at CastError (E:\imooc\node_modules\mongoose\lib\error\cast.js:26:11)
at ObjectId.cast (E:\imooc\node_modules\mongoose\lib\schema\objectid.js:149:13)
at ObjectId.SchemaType._castForQuery (E:\imooc\node_modules\mongoose\lib\schematype.js:1048:15)
at ObjectId.castForQuery (E:\imooc\node_modules\mongoose\lib\schema\objectid.js:189:15)
at ObjectId.SchemaType.castForQueryWrapper (E:\imooc\node_modules\mongoose\lib\schematype.js:1014:15)
at cast (E:\imooc\node_modules\mongoose\lib\cast.js:268:32)
at model.Query.Query.cast (E:\imooc\node_modules\mongoose\lib\query.js:2993:12)
at model.Query.Query.findOne (E:\imooc\node_modules\mongoose\lib\query.js:1397:10)
at E:\imooc\node_modules\mongoose\lib\query.js:2806:21
at new Promise.ES6 (E:\imooc\node_modules\mongoose\lib\promise.js:45:3)
at model.Query.exec (E:\imooc\node_modules\mongoose\lib\query.js:2800:17)
at Function.findById (E:\imooc\schemas\movie.js:44:5)
at E:\imooc\app.js:69:9
at Layer.handle [as handle_request] (E:\imooc\node_modules\express\lib\router\layer.js:95:5)
at next (E:\imooc\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (E:\imooc\node_modules\express\lib\router\route.js:112:3)
message: 'Cast to ObjectId failed for value "undefined" at path "_id" for model "Movie"',
name: 'CastError',
stringValue: '"undefined"',
kind: 'ObjectId',
value: 'undefined',
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: 'localhost',
port: 27017,
user: undefined,
pass: undefined,
name: 'imooc',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
db: [Object] },
discriminators: undefined,
fetch: [Function: fetch],
findById: [Function: findById],
_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: [Object],
opts: [Object],
name: 'movies',
collectionName: 'movies',
conn: [Object],
queue: [],
buffer: false,
emitter: [Object] },
Query: { [Function] base: [Object] },
'$__insertMany': [Function],
insertMany: [Function] } }
events.js:163
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'save' of undefined
at E:\imooc\app.js:75:10
at E:\imooc\node_modules\mongoose\lib\query.js:2823:9
at newTickHandler (E:\imooc\node_modules\mpromise\lib\promise.js:234:18)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
举报