Я пытаюсь отправить данные с помощью экспресс, но по какой-то причине он теряет часть данных.Экспресс res.json() Потеря данных
function(err, data) {
if (err) console.log(err);
console.log(data);
res.json(data);
}
Variable данных выглядит (упрощенный):
{field1: 'value1', field2: 'value2', field3: {subfield: 'subvalue'}}
Но в браузере я получаю:
{field1: 'value1', field2: 'value2', field3: null }
Я делаю что-то неправильно или что-то отсутствует?
Update:
Полный код
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 в браузере является недействительным.
Update 2:
Результат console.log (данные):
{ Issues:
[ 575efe1c3d6d04662a2cd1c4
575efe1c3d6d04662a2cd1d3 ],
Stopped: false,
InFuture: false,
__v: 0,
SeriesId:
{ SeriesName: 'Test name',
_id: 575efe1b3d6d04662a2cd188 },
UserId: 561c080aa849427a8699cafd,
_id: 575f0981ddac1c802d9d1536 }
Update 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, и это первый время, когда я использовал монго.
Что такое 'data'? Откуда он? – robertklep
Я обновил вопрос с полным кодом – emwsc
Действительно ли 'user.id' существует в БД? – peteb