Gigya Job Openings

ds.get JS

Skip to end of metadata
Go to start of metadata

Description

 

Retrieves an object data from Gigya's Data Store.
For security reasons, you may only retrieve objects that are associated with the currently logged-in user.

Note: If you plan on integrating the DS, we highly recommend reading the Data Store Guide.
The DS is a premium platform that requires separate activation. If the DS is not part of your site package please contact your Gigya Customer Engagement Executive or email support@gigya-inc.com.


 

Syntax

 

 

Parameters

The following table lists the available parameters:

RequiredNameTypeDescription
oidstringThe ID of the object to retrieve.
typestring A string indicating the type of the object.
fieldsstringA comma separated list of fields to retrieve. Acceptable values for this parameter:
  • Data field names, specifying the the complete path, i.e. album.photo.photoTitle_t
  • Partial field names (fields that contain only a part of the path to sub-objects, i.e. album.photo) - indicate to retrieve everything below that path.
  • "*" - indicates to retrieve the entire stored object.
callbackfunction
A reference to a callback function. Gigya calls the specified function along with the results of the API method when the API method completes.
The callback function should be defined with the following signature: functionName(Response).
The "Response Object Data Members" table below provides specification of the data that is passed to the callback function.
contextobject
A developer-created object that is passed back unchanged to the application as one of the fields in the response object.

 

Response Object Data Members

FieldTypeDescription
errorCode integer The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Response Codes and Errors table.
errorMessage string A short textual description of an error associated with the errorCode for logging purposes.
callId string Unique identifier of the transaction, for debugging purposes.
context object The context object passed by the application as a parameter to the API method, or null if no context object has been passed.
dataJSON objectThe object data retrieved from Gigya's Data Store.
oidstringThe ID of the object
UIDstringIf the object is associate with a user, then the ID of the user.
lastUpdatedlongThe time of the latest change in this object, in Java time (number of milliseconds since Jan. 1st 1970).
lastUpdatedTimestringThe time of the latest change in this object, in ISO 8601 format.
createdlongThe time of this object's creation, in Java time (number of milliseconds since Jan. 1st 1970).
createdTimestringThe time of this object's creation, in ISO 8601 format.

 

Code Sample

// Callback function - print results
function printResult(response) { 
    if ( response.errorCode == 0 ) {  
        if ( null!=response.data ) {  
            alert("Car year: " + response.data.car.year_i + ",  Brand: " + response.data.car.brand_s + ",  Owner: " + response.data.car.owner_s + "\n\n");
        }
        else {
            alert('No data returned');
        }
    } else {
        alert('Error :' + response.errorMessage);
    }
};

var params={
    oid: 1234,
    type: "car",
    fields: "year_i, brand_s, owner_s",
    callback: printResult 
}

// Call getUserData method
gigya.ds.get(params);

Notes:

  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • To run the code on your own domain, add your Gigya API key to the gigya.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.
  • In some cases it is necessary to connect/login the user to a provider ? prior to calling the API method. You can learn more in the Social Login guide.