当我使用下面的代码访问当前用户的类行时?Parse 报告该函数返回一个数据集,因此:
{"user":{"__type":"Pointer""className":"_User""objectId":"NFYHCP6Ftw"}
"known_fieldname":"Value"
"known_fn2":"value2"
"known_fn3":"value3"
"objectId":"obFbHtMW4E"
"createdAt":"2014-09-16T15:47:55.047Z"
"updatedAt":"2014-09-16T16:10:55.318Z"
"__type":"Object"
"className":"Answers"}
解析云代码:
Parse.Cloud.define("Answers", function(request, response) {
var query = new Parse.Query("Answers");
query.equalTo("user", Parse.User.current());
query.first({
success: function(obj) {
// kick out "value"...
console.log("A field I know="+obj.get("known_fieldname"));
// this for loop doesn't loop thru the field "keys" and "values"
// what do I replace it with?
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
console.log("Answer="+obj.get(key));
// add to a dictionary to return to caller
}
}
response.success(obj);
},
error: function() {
response.error("Failed to get any answers.");
}
});
});