Tables are Java objects used within The Othernet for persistent data storage and retrieval. Tables specified
within the Architect's plans will be automatically accessible to the Builder's code.
If a Table contains DataObjects owned by specific users, calls must include the userID argument.
// Delete all DataObjects with a status of cancelled
table.deleteObjects( "status", "=", "cancelled" );
// Return all DataObjects with numFriends greater than 500 and a country of us
// Notice 500 has a numeric value and is not a String
DataObject[] friendlyPeople = table.returnObjects( "numFriends", ">", 500, "AND", "country", "=", "us" );
The final element in a query can be the orderBy String.
// Return all objects with a status of unshipped, ordered by zipcode
DataObject[] packages = table.returnObjects( "status", "=", "unshipped", "ORDER BY zipCode" );
Adding DataObjects to the Table
// Add a DataObject to the Table
addObject( DataObject o );
// Add a DataObject owned by a specific user to the Table
addObject( int userID, DataObject o );
Retrieving Objects
// Return a DataObject with a specific objectID
DataObject returnObjectByID( int objectID );
// Return a DataObject with a specific objectID
// Only returns the DataObject if userID has read access
DataObject returnObjectByID( int userID, int objectID );
// Return all DataObjects from the Table
DataObject returnAllObjects();
// Return all DataObjects from the Table that userID has read access to
DataObject returnAllObjects( int userID );
// Return all DataObjects from the Table, sort by orderBy
DataObject returnAllObjects( String orderBy );
// Return all DataObjects from the Table, sort by orderBy
// Only returns DataObjects userID has read access to
DataObject returnAllObjects( int userID, String orderBy );
// Return DataObjects that match a given query
DataObject[] returnObjects( Query... );
// Return DataObjects that match a given query
// Only returns those objects that the userID has read access for
DataObject[] returnObjects( int userID, Query... );
// Return a single DataObject that matched a given query
// Throws an error if more than one object is found
DataObject returnObject( Query... );
// Return a single DataObject that matches a given query
// and that a userID has read access for
// Throws an error if more than one object is found
DataObject returnObject( int useID, Query... );
Updating Objects
// Update a specific DataObject
// Used when a DataObject is retrieved from the Table, and then modified
// The Table will then contain the modified version of the object
updateObject( DataObject o );
// Update a specific DataObject
// Only succeeds if userID has proper write access
updateObject( int userID, DataObject o );
// Update the DataObject with a certain objectID
void updateObjectByID( int objectID, DataObject o );
// Update the DataObject with a certain objectID
// Only succeeds if userID has proper write access
void updateObjectByID( int userID, int objectID, DataObject o );
// Replace all DataObjects that match a given query with the given object
void updateObjects( DataObject o, Query... );
// Replace all DataObjects that match a given query with the given object
// Update only occurs if userID has proper write access
void deleteObjects( int userID, Query... );
Deleting Objects
// Delete a specific DataObject
deleteObject( DataObject o );
// Delete the DataObject with a certain objectID
deleteObjectByID( int objectID );
// Delete the DataObject with a certain objectID
// Deletion only succeeds if userID has proper write access
deleteObjectByID( int userID, int objectID );
// Delete DataObjects that match a given query
deleteObjects( Query... );
// Delete DataObjects that match a given query
// Deletion only occurs if userID has proper write access
deleteObjects( int userID, Query... );
Checking for Object existence
// Check to see if a specific objectID exists in the Table
boolean existsID( DataObject o, Query... );
// Check to see if any objects exist that match the given query
boolean exists( DataObject o, Query... );
// Check to see if userID can read any objects that match the given query
boolean exists( int userID, Query... );
Modifying Read Access for User Objects
// Grant read access to a specific userID for a given objectID
addReadAccess( int objectID, int userID );
// Remove read access to a specific userID for a given objectID
removeReadAccess( int objectID, int userID );