com.stackmob.sdkapi
Interface DataService


public interface DataService

DataService allows you to interact with your data on StackMob


Method Summary
 SMObject createObject(String schema, SMObject toCreate)
          Creates a new object in the datastore.
 Boolean deleteObject(String schema, String id)
          Deletes an object in the datastore.
 Set<String> getObjectModelNames()
          Retrieves a list of the object models declared for the current application.
 List<SMObject> readObjects(String schema, List<SMCondition> conditions)
          Reads a list of objects matching the given query fields from the datastore.
 List<SMObject> readObjects(String schema, List<SMCondition> conditions, List<String> fields)
          Reads a list of objects matching the given query fields from the datastore, returning only the specified fields
 SMObject updateObject(String schema, String id, List<SMUpdate> updateActions)
          Updates an object in the datastore.
 void updateObjects(String schema, List<SMCondition> conditions, List<SMUpdate> updateActions)
          Updates all objects matching the given query in the datastore
 

Method Detail

createObject

SMObject createObject(String schema,
                      SMObject toCreate)
                      throws InvalidSchemaException,
                             DatastoreException
Creates a new object in the datastore. Each such object should be represented as a map of field names to objects, where each sub-object is a List, Map, String, Long, or Double depending on the type of the field in question.

Parameters:
schema - the name of the relevant object schema
toCreate - the object to create; must match the schema declared for the relevant object type
Returns:
the object created
Throws:
InvalidSchemaException - if the object to create does not match the relevant schema
DatastoreException - if the connection to the datastore fails or the datastore encounters an error

readObjects

List<SMObject> readObjects(String schema,
                           List<SMCondition> conditions)
                           throws InvalidSchemaException,
                                  DatastoreException
Reads a list of objects matching the given query fields from the datastore.

Parameters:
schema - the name of the relevant object model
conditions - the list of conditions which comprise the query
Returns:
a list of all documents matching the query
Throws:
InvalidSchemaException - if the schema specified does not exist, or the query is incompatible with the schema
DatastoreException - if the connection to the datastore fails or the datastore encounters an error

readObjects

List<SMObject> readObjects(String schema,
                           List<SMCondition> conditions,
                           List<String> fields)
                           throws InvalidSchemaException,
                                  DatastoreException
Reads a list of objects matching the given query fields from the datastore, returning only the specified fields

Parameters:
schema - the name of the relevant object model
conditions - the list of conditions which comprise the query
fields - the list of fields to be returned; regardless of what is specified, the id will always be returned
Returns:
a list of all documents matching the query
Throws:
InvalidSchemaException - if the schema specified does not exist, or the query is incompatible with the schema
DatastoreException - if the connection to the datastore fails or the datastore encounters an error

updateObject

SMObject updateObject(String schema,
                      String id,
                      List<SMUpdate> updateActions)
                      throws InvalidSchemaException,
                             DatastoreException
Updates an object in the datastore.

Parameters:
schema - the name of the relevant object model; must be a type already declared for the current application
id - the id of the object to update
updateActions - the actions to take on the object being updated
Returns:
the updated object
Throws:
InvalidSchemaException - if the schema does not exist, or the update actions are incompatible with it
DatastoreException - if the connection to the datastore fails or the datastore encounters an error

updateObjects

void updateObjects(String schema,
                   List<SMCondition> conditions,
                   List<SMUpdate> updateActions)
                   throws InvalidSchemaException,
                          DatastoreException
Updates all objects matching the given query in the datastore

Parameters:
schema - the name of the relevant object model; must be a type already declared for the current application
query - the query used to find objects to update
updateActions - the actions to take on the object being updated
Throws:
InvalidSchemaException - if the schema does not exist, or the update actions are incompatible with it
DatastoreException - if the connection to the datastore fails or the datastore encounters an error

deleteObject

Boolean deleteObject(String schema,
                     String id)
                     throws InvalidSchemaException,
                            DatastoreException
Deletes an object in the datastore.

Parameters:
schema - the name of the relevant object model; must be a type already declared for the current application
id - the id of the object to delete
Returns:
a Boolean object representing success (Boolean.TRUE) or failure (Boolean.FALSE)
Throws:
InvalidSchemaException - if the object model specified does not exist
DatastoreException - if the connection to the datastore fails or the datastore encounters an error

getObjectModelNames

Set<String> getObjectModelNames()
                                throws ConnectException
Retrieves a list of the object models declared for the current application.

Returns:
the set of all valid object model names
Throws:
ConnectException - if the list of object models cannot be retrieved


Copyright © 2012 StackMob. All Rights Reserved.