javascript - Can't retrieve all records from Cloudkit Cloud (JS) -
i have html table want populate values stored in cloudkit dashboard.
i have retrieved records , populated tables them, , problem noticing if give time , try reload table again records not retrieved. haven't changed of code in time between, i'm puzzled how/why happening. below example of code, , error log:
public-query.js :
records.foreach(function(record) { var fields = record.fields; var tableactual = "<tr><td>" + record['created'].timestamp + "</td><td>" + fields['placename'].value + </td></tr> document.write(tableactual)
error log:
uncaught (in promise) typeerror: cannot read property 'timestamp' of undefined @ public-query.js:49:73 @ array.foreach (native) @ public-query.js:47:29
if remove example <td>" + record['created'].timestamp + "</td>
error log next <td>
undefined.
to clear, there record being retrieved timestamp correctly, , there other records being retrieved , aren't, no change in code.
i've received error @ different times in different parts of line 3 (in actual code there 16 fields/<td>
) though know fields populated in record, , have retrieved records fields unpopulated.
any idea what's going on here? bug cloudkit or doing wrong?
if take @ discussion section @ bottom of cloudkit web services query reference, you'll see:
indexes updated asynchronously not guaranteed current.
it's possible records returned in query marked deleted , won't include fields, need check before assuming fields exist , access them. here example response might see:
{ "records": [{ "recordname": "195055b3-1db7-4d75-86f0-d9aef8d8381b", "deleted": true }, { "recordname": "712525a8-eccf-4da7-b2d9-981f120bcc82", "deleted": true }], "total": 2 }
if check deleted attribute on these objects can ignore them when processing or rendering data.
Comments
Post a Comment