Start a new topic
Answered

Returned file object is incomplete returned if I use query.fields

I have a collection where every record has an image (thumbnail). Name of the filed is "thumbnail" and it contains this:


{

  "_id": "thumb-n9ojr7aa8",

  "size": 7099,

  "mimeType": "image/jpeg",

  "_filename": "34d1ebd4-4728-455e-8807-190a00798695",

  "_acl": {

    "creator": "54aeae56c0f223865101f894"

  },

  "_kmd": {

    "lmt": "2015-04-17T10:07:44.009Z",

    "ect": "2015-04-16T15:28:33.802Z"

  },

  "_downloadURL": "http://storage.googleapis.com/kinvey_production_da839956b9c54d749b196e68a2fb7d5b/thumb-n9ojr7aa8/34d1ebd4-4728-455e-8807-190a00798695?GoogleAccessId=558440376631@developer.gserviceaccount.com&Expires=1429270998&Signature=NItWQ4qmthOXjXNpEP73%2BHTxFAUegSzKOQlbO%2F4mIi0hMuJhiJ2AttAZFvM1bqeLGPXwhiil3VgqzZ5amZ%2Bt9LQ%2FJfaDTrh4uD1WKVqMhVmiG3o0AfIoLiOGdsB5RUAKyiFcxfItDDO3Fd8f32pYbCDTFsqG2%2BdTSCTIpuH7wZo%3D",

  "_expiresAt": "2015-04-17T11:43:18.250Z",

  "_type": "KinveyFile"

}


When I request the record via Kinvey.DataStore.find with no query parameter it returns the thumbnail object with all the data including the _downloadURL, but when I use query to limit the number of fields (e.g. query = query.fields(["_id", "name", "pies", "flows", "thumbnail"]); the thumbnail object I receive does not contain the _downloadURL any more, it only contains 


{_type: "KinveyFile", _id: "thumb-jhtk3ccoi"}.


Why? How do I get limited fields from my collection while also receiving the _downloadURL of my thumbnail?


Best Answer

Good morning again Daniel,


Our wonderful JS developer Thomas has whipped up a query that should solve the issues that you are running into:


var query = new $kinvey.Query();
query.equalTo('name', ‘John Doe');
query.fields(['_id', 'thumbnail']);
$kinvey.DataStore.find('employees', query, {
  relations: {
    thumbnail: 'files'
  }
}).then(function(response) {
  console.log(response);
});


We think that this should grab what you need.   The relations bit is what is grabbing the downloadURL for you


Please let me know if you have any other questions,



nice workaround, thanks 

Answer

Good morning again Daniel,


Our wonderful JS developer Thomas has whipped up a query that should solve the issues that you are running into:


var query = new $kinvey.Query();
query.equalTo('name', ‘John Doe');
query.fields(['_id', 'thumbnail']);
$kinvey.DataStore.find('employees', query, {
  relations: {
    thumbnail: 'files'
  }
}).then(function(response) {
  console.log(response);
});


We think that this should grab what you need.   The relations bit is what is grabbing the downloadURL for you


Please let me know if you have any other questions,


Login or Signup to post a comment