Keystone js – populateRelated字段显示为未定义

每个应用程序与用户有1对1的关系。 每个旅程都有n个应用程序

下面是我的以下代码,用于在所有旅程的应用程序中填充所有用户(学生)数据:

view.on('init', function(next) { Trip.model.find() .exec(function(err, trips){ keystone.populateRelated(trips, 'students[user]', function(err) { locals.trips = trips; next(); }); }); }); 

这是Trips与应用程序(StudentApp)的关系:

 Trip.relationship({ ref: 'StudentApp', refPath: 'finalTrip', path: 'students' }); 

现在在前端,我可以打印一个用户的string化的JSON就好了:

 each trip in trips each app in trip.students p=app.user 

然而,当我尝试访问一个字段,例如app.user._id我得到以下错误:

 Cannot read property '_id' of undefined 

我感觉这是一个asynchronous的问题,但我不能为了我的生活找出如何解决这个问题。

帮助将不胜感激。 谢谢。