2
급행을 사용하여 데이터를 보내려고하지만 어떤 이유로 데이터가 손실됩니다.Express res.json() 데이터 손실
{field1: 'value1', field2: 'value2', field3: {subfield: 'subvalue'}}
을하지만 브라우저에서 나는 나타납니다 :
function(err, data) {
if (err) console.log(err);
console.log(data);
res.json(data);
}
변수 데이터 (간체)과 같은
{field1: 'value1', field2: 'value2', field3: null }
내가 뭔가 잘못하고 또는 뭔가를 놓치고 있습니까?
는 업데이트 :
전체 코드
UserReadingData.find({
UserId: {
"$exists": true,
"$eq": user._id
},
InFuture: false,
Stopped: false
})
.populate('SeriesId', 'SeriesName')
.exec(function(err, data) {
if (err) console.log(err);
console.log(data);
res.json(data);
});
그리고 SeriesId 브라우저에서 null입니다.
업데이트 2 : CONSOLE.LOG (데이터)의
결과 :
{ Issues:
[ 575efe1c3d6d04662a2cd1c4
575efe1c3d6d04662a2cd1d3 ],
Stopped: false,
InFuture: false,
__v: 0,
SeriesId:
{ SeriesName: 'Test name',
_id: 575efe1b3d6d04662a2cd188 },
UserId: 561c080aa849427a8699cafd,
_id: 575f0981ddac1c802d9d1536 }
업데이트 3 :
내 스키마
var seriesSchema = mongoose.Schema({
Meta: metaInformationSchema,
SeriesName: String,
Description: String,
Creators: [creatorsSchema],
Featured: [featuredSchema],
PublisherName: String,
IsStoryArc: Boolean,
Issues: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Issue'
}]}, {
collection: 'library'});
var userReadingDataSchema = mongoose.Schema({
UserId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
},
SeriesId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Series'
},
Issues: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Issue'
}],
InFuture: Boolean,
Stopped: Boolean}, {collection: 'readingdata'});
내가 SQL에서 와서 처음이야 내가 몽고를 사용할 때.
'데이터'는 정확히 무엇입니까? 이것은 어디서 오는 거니? – robertklep
전체 코드로 질문을 업데이트했습니다 – emwsc
DB에'user.id'가 실제로 있습니까? – peteb