Skip to content

Enginio Data Storage SDK API

Miska Kaipiainen edited this page Mar 23, 2014 · 7 revisions

EDS - Constructor

EDS - Helper functions for working with custom data types

EDS - Collections

EDS - Files

EDS - Custom REST API requests

Qtc.Eds()

var eds = new Qtc.Eds( options );

The constructor for EDS instance. The options is an object with following parameters:

  • address - An address of this EDS instance
  • backendId - A backend id of this EDS instance
  • secret - (optional) A security token for this EDS instance
// The typical constructor may look something like this...
var eds = new Qtc.Eds({
   address: "",     // enter your EDS instance address
   backendId: "",   // enter your EDS instance backend id
   secret: ""       // enter your EDS instance secret token
});

Qtc.Eds.rest()

eds.rest( verb, path, options, callback );

The custom rest request to EDS instance. Arguments:

  • verb - A HTTP request verb: GET, POST, PUT, DELETE
  • path - A path for the request. Please see http://developer.qtc.io/eds/rest/reference
  • options - (optional) An options for the request
  • callback - A callback function to be called when request is completed.
// example of using the custom REST API call to get objects in collection "places"
eds.rest("GET", "/objects/places", function(e, result){
   // do something with result
});

Qtc.Eds.collection()

var collection = eds.collection( name, useInternals );

Assign collection instance. Arguments:

  • name - A name of the collection.
  • useInternals - (optional) This boolean value applies only if the collection name is "users" or "usergroups". If set to true, the collection points to EDS users and usergroups collection. If not set, the collection points to custom user defined objects.

Returns a collection instance.

// assign collection "places" to variable
var places = eds.collection("places");

// do something with collection...

Qtc.Eds.collection.insert()

collection.insert( obj, callback );

Inserts an object into collection. Arguments:

  • obj - An object to be inserted.
  • callback - A callback function called after the operation. Callback function is called with two arguments: callback(error, result).
    • error - The error code. If the request is successful, error is null.
    • result - The response to request.
// example: assume we have collection "places"
places.insert({ name: "Paris", country: "France" }, function(e,result){
   // do something with collection...
});

Qtc.Eds.collection.update()

collection.update( objId, obj, callback );

Updates an object in a collection. Arguments:

  • objId - An object id to be updated.
  • obj - An object containing the updated fields.
  • callback - A callback function called after the operation. Callback function is called with two arguments: callback(error, result).
    • error - The error code. If the request is successful, error is null.
    • result - The response to request.
// example: assume we have collection "contacts"
contacts.update( "532ed53900deff4eee0003ee", {
    email: "batman@newemailaddress.org"
}, function(e, result){
   // do something with result
});