0
캐스팅 오류가 ObjectId
입니다. 문서의 제목을 찾기 위해 노력하고 있습니다.mongoose 객체 ID 오류 발견
var mongoose=require('mongoose');
var Schema=mongoose.Schema;
var contentSchema = new Schema({
language: String,
genres : String,
title : {
type: [String],
required: true
},
cast : {name : [String]} ,
storyline : String,
videoUrl : String,
path : String,
contentType : String,
duration : String,
rating : String,
tvCardImageUrl : String,
tvBgImageUrl : String,
mobileCardImageUrl : String,
mobileImageUrl : String,
tabletCardImageUrl : String,
tabletBgImageUrl : String,
publishedDate : Date,
uploadedDate : Date,
});
module.exports=mongoose.model('contents',contentSchema);
router.route('/content/card').get(function(req, res){
Content.find({language: 'English'})
.select('title')
.exec(function(err, content){
if(err)
res.send(err);
res.json(content);
});
});
오류
"message": "Cast to ObjectId failed for value \"card\" at path \"_id\"",
"name": "CastError",
"kind": "ObjectId",
"value": "card",
"path": "_id"
당신은 나를 어떻게 반환 캐스팅 ObjectId가 알려 주시기 바랍니다 수 있습니까?
추가 _id : 스키마 파일의 문자열이 여전히 작동하지 않습니다. – user3401694
null 객체가 반환되었습니다. – user3401694
@JohnnyHK String으로 변경된 후 작동했습니다. 내 나쁜 내가 worg ID를 넘겨받은 이유는 null 객체를 반환하기 때문입니다. 조니, 고마워. – user3401694