我正在使用Parse.com作为基于Trigger.io的Android应用的后端。我的问题非常基本,而且我确信这只是对javascript的一些基本理解,我还没有掌握 - 我还在学习很多关于语言的知识。
当我查询Parse以获取对象数组并记录响应时,我得到了我需要的一切:每个对象的属性,唯一对象id,createdAt,updatedAt等。以下是Parse中单个对象的示例:
来自Parse的[INFO] 10-03 10:34:21.992 18060 18072 I Forge : [FORGE] [INFO] 10-03 10:34:21.992 18060 18072 I Forge : [ { attributes: [INFO] 10-03 10:34:21.992 18060 18072 I Forge : { first_name: 'John', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : last_name: 'Smith', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : email: 'john.smith@aol.com', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : phone: '5551112234', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : address: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : city: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : state: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : zip: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : race: '7', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : theDate: '10/02/2012', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : formName: 'DriverWaiver', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : imported: true }, [INFO] 10-03 10:34:21.992 18060 18072 I Forge : _operations: {}, [INFO] 10-03 10:34:21.992 18060 18072 I Forge : _dirty: {}, [INFO] 10-03 10:34:21.992 18060 18072 I Forge : _hashedJSON: {}, [INFO] 10-03 10:34:21.992 18060 18072 I Forge : _escapedAttributes: {}, [INFO] 10-03 10:34:21.992 18060 18072 I Forge : cid: 'c38', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : id: 'beLlUqrUBl', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : createdAt: '2012-10-02T17:51:38.267Z', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : updatedAt: '2012-10-02T17:51:38.267Z', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : _setting: false, [INFO] 10-03 10:34:21.992 18060 18072 I Forge : _previousAttributes: [INFO] 10-03 10:34:21.992 18060 18072 I Forge : { first_name: 'John', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : last_name: 'Smith', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : email: 'john.smith@aol.com', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : phone: '5551112234', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : address: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : city: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : state: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : zip: '', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : race: '7', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : theDate: '10/02/2012', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : formName: 'DriverWaiver', [INFO] 10-03 10:34:21.992 18060 18072 I Forge : imported: true } },
然而,在保存结果后,没有变量操作,使用Trigger.io的forge.prefs.set(),我只能读取属性。使用forge.prefs.get()后,这是同一个对象:
[INFO] 10-03 11:05:44.594 19055 19068 I Forge : [FORGE] [INFO] 10-03 11:05:44.594 19055 19068 I Forge : [ { first_name: 'John', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : last_name: 'Smith', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : email: 'john.smith@aol.com', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : phone: '5551112233', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : address: '', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : city: '', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : state: '', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : zip: '', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : race: '7', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : theDate: '10/02/2012', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : formName: 'DriverWaiver', [INFO] 10-03 11:05:44.594 19055 19068 I Forge : imported: true },
var FormData = Parse.Object.extend(formName); var query = new Parse.Query(FormData); var currentYear = new Date().getFullYear(); query.endsWith("theDate", currentYear.toString()); query.limit(1000); query.descending('imported'); // get from parse query.find({ success: function(results) { // got from Parse if (formName == "DriverWaiver") forgeLog(results); // save to local forge.prefs.set(formName, results, function(){ // saved to local forgeLog("Saved to Local"); // get from local forge.prefs.get(formName, function(results){ // got from local forgeLog("Got from Local"); if (formName == "DriverWaiver") forgeLog(results); }, function(){ // error getting from local forgeLog("Error getting from Local"); }); }, function (){ // error saving to local forgeLog("Error saving to Local"); }); }, error: function(error) { // error getting from parse forgeLog("Error getting data from Parse"); } });
所以我想我的问题是:我如何保存整个对象?我真的需要为我的应用程序保存的唯一ID才能正常运行。
我向Trigger支持发送了完整的日志记录输出,他们认为这是一个Parse API问题,并将我推迟给他们。我不相信它是一个Parse问题,但我没有反复支持渠道,我希望这里的社区可以提供一些见解。提前谢谢!