javascriptiosmetadatacloudkitcloudkit-web-services

How to query for Metadata in CloudKit JS?


I've figured out how to query for some metadata for example calling this in my query:

<td>" + record['created'].value + "</td> <-- populates some table data

But this comes back undefined which confuses me because the CloudKit dashboard has a value for Created By (as part of the automatic Metadata that is created with each record.)

How do I query for the ID/UUID as well as get the response in a HTML/JS-readable manner?


Solution

  • After fetching one or more records with CloudKit.js you'll notice you get back an Object that looks like this:

    {
        "recordName": "6E863D3D-5371-4376-A9BA-3B294F480E4E",
        "recordType": "Message",
        "fields": {
            "text": {
                "value": "hi",
                "type": "STRING"
            },
        },
        "recordChangeTag": "ib461v1s",
        "created": {
            "timestamp": 1434751588720,
            "userRecordName": "_36ed4b61e7a11c9302f851fe25a9b911",
            "deviceID": "_2"
        },
        "modified": {
            "timestamp": 1434751588720,
            "userRecordName": "_36ed4b61e7a11c9302f851fe25a9b911",
            "deviceID": "_2"
        }
    }
    

    The recordName is a record's unique identifier, and the Object has a created attribute which points to an Object with a timestamp field.