嗨,我正在stackato上安装一个应用程序,我得到了以下错误:
2014-03-07T03:30:44-0800分期: /staging/staged/app/node_modules/mongoose/lib/utils.js:419 2014-03-07T03:30:44-0800分期:抛错;2014-03-07T03:30:44-0800分段:^ 2014-03-07T03:30:44-0800分段: CastError:转换为ObjectId失败,值为"21trt5sdsdesd111521“,路径为"userStories”2014-03-07T03:30:44-0800分段: at ObjectId.cast 2014-03-07T03:30:44-0800分段:at Array.MongooseArray._cast (/staging/staged/app/node_modules/mongoose/lib/types/array.js:108:30) 2014-03-07T03:30:44-0800暂存: at Object.map (本机) 2014-03-07T03:30:44-0800暂存: at Array.MongooseArray.push (/staging/staged/app/node_modules/mongoose/lib/types/array.js:262:23) 2014-03-07T03:30:44-0800暂存:在(/staging/staged/app/tools/setup-db-demo.js:234:25) (/staging/staged/app/node_modules/mongoose/node_modules/mpromise/lib/promise.js:162:8) 2014-03-07T03:30:44-0800暂存:在Promise.createProjectByDefault Promise.onResolve 2014-03-07T03:30:44-0800暂存:在Promise.EventEmitter.emit (2014-03-07T03:30:44-0800暂存: at Promise.emit (/staging/staged/app/node_modules/mongoose/node_modules/mpromise/lib/promise.js:92:20) 2014-03-07T03:30:44-0800暂存: at events.js:96:17 Promise.emit 2014-03-07T03:30:44-0800暂存: at Query.findOne (/staging/staged/app/node_modules/mongoose/lib/query.js:1784:30) 2014-03-07T03:30:44-0800 stackato.stager:已完成暂存应用程序'jat‘
下面是它所引用的代码部分
var story1 = new userStoryModel ({
id : '21trt5sdsdesd111521',
project : reg.id,
title : 'Moving a US from the Current to Done',
storyType : 'Feature',
points : '5',
isEstimated : true,
requester : player2.id,
owner : player1.id,
description : 'test test test.',
task : []
});你知道为什么不能工作吗?
发布于 2014-03-08 01:16:11
这很可能是因为您的UserStoryModel模式需要一个ObjectID而不是一个字符串作为id。我也不明白为什么它是"id“而不是"_id”,但也许你的特定框架会转换它。
试一试
var ObjectID = require('mongodb').ObjectID; //your particular framework may have an easier way to access this than requireing mongodb
var story1 = new userStoryModel ({
id : new ObjectID('21trt5sdsdesd111521'),
project : reg.id,
title : 'Moving a US from the Current to Done',
storyType : 'Feature',
points : '5',
isEstimated : true,
requester : player2.id,
owner : player1.id,
description : 'test test test.',
task : []
});https://stackoverflow.com/questions/22254309
复制相似问题