您好我正在stackato上安装应用程序,我收到以下错误:
2014-03-07T03:30:44-0800登台:/staging/staged/app/node_modules/mongoose/lib/utils.js:419 2014-03-07T03:30:44-0800 staging:throw err; 2014-03-07T03:30:44-0800分期:^ 2014-03-07T03:30:44-0800 staging:CastError:对于路径“userStories”的值“21trt5sdsdesd111521”,转换为ObjectId失败 2014-03-07T03:30:44-0800 staging:at ObjectId.cast(/staging/staged/app/node_modules/mongoose/lib/schema/objectid.js:116:13) 2014-03-07T03:30:44-0800 staging:at Array.MongooseArray._cast(/staging/staged/app/node_modules/mongoose/lib/types/array.js:108:30) 2014-03-07T03:30:44-0800 staging:at Object.map(native) 2014-03-07T03:30:44-0800 staging:at Array.MongooseArray.push(/staging/staged/app/node_modules/mongoose/lib/types/array.js:262:23) 2014-03-07T03:30:44-0800 staging:在Promise.createProjectByDefault(/staging/staged/app/tools/setup-db-demo.js:234:25) 2014-03-07T03:30:44-0800 staging:at Promise.onResolve(/staging/staged/app/node_modules/mongoose/node_modules/mpromise/lib/promise.js:162:8) 2014-03-07T03:30:44-0800 staging:at Promise.EventEmitter.emit(events.js:96:17) 2014-03-07T03:30:44-0800 staging:at Promise.emit(/staging/staged/app/node_modules/mongoose/node_modules/mpromise/lib/promise.js:79:38) 2014-03-07T03:30:44-0800 staging:at Promise.fulfill(/staging/staged/app/node_modules/mongoose/node_modules/mpromise/lib/promise.js:92:20) 2014-03-07T03:30:44-0800 staging: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 : []
});
任何想法为什么不起作用?
答案 0 :(得分:0)
这很可能是因为您的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 : []
});