我已按照this指南在AWS Elastic Beanstalk上设置了Parse-Server。然后,我编写了一个云代码函数,它从特定的类/集合中获取单个记录。该集合包含大约20列。但是,作为查询结果提取的对象仅包含大约8列。我确保记录确实在查询遗漏的列中有数据。我在这里遗漏了什么,还是在Parse中有一些限制?有没有办法强制Parse获取这些列?
Parse.Cloud.define('confirmAppointment', function(request, response) {
var staffId = request.params.staffId;
var appointmentId = request.params.appointmentId;
var appointmentRequest = Parse.Object.extend("AppointmentRequest");
appointmentRequest.id = appointmentId;
appointmentRequest.staffId = staffId;
var query = new Parse.Query(appointmentRequest);
query.first({
useMasterKey: true,
success: function(appointment) {
if (appointment) {
// these fields are not found in the fetched appointment object
// they do exist however in mongodb
var requesterUserId = appointment.get("requesterUserId");
var staffUserId = appointment.get("staffUserId");
var staffName = appointment.get("staffNameEn");
...
}
}
...
});
});
答案 0 :(得分:0)
您的代码中可能存在一些拼写错误(查询部分的构造)。试试这个:
Parse.Cloud.define('confirmAppointment', function(req, res) {
var staffId = req.params.staffId;
var appointmentId = req.params.appointmentId;
var query = new Parse.Query("AppointmentRequest");
query.equalTo('objectId', appointmentId);
query.equalTo('staffId', staffId);
query.first({
useMasterKey: true,
success: function(appointment) {
res.success(appointment.get("requesterUserId"));
},
error: function(err) {
res.error(err);
}
});
});
答案 1 :(得分:0)
问题是,当我将数据从Parse迁移到我的mongolab托管的MongoDB实例时,我没有在Parse migration向导中单击“Finalize”按钮。这是故意的,因为Parse警告我单击Finalize会使迁移永久化,我将无法再回到Parse托管数据库。另一方面,我可以看到所有数据都已成功迁移到mongolab,从技术上讲,应该足以让我的AWS托管解析服务器在这个新数据库上运行而不会出现任何问题。但不知何故,单击Parse中的“Finalize”按钮会产生一些魔力(我仍然不明白它可能是什么)并且我的查询开始返回预期的结果。
我在迁移到Heroku时也能够重现同样的问题,所以我确信它与AWS无关。
希望这会对某人有所帮助。