This object represents a datastash (i.e. lightweight database). New SPDatastash objects are created using the SPDatastash top-level method.
Method: addObject
Adds a single object to the stash
SPDatastashObject addObject();
SPDatastashObject addObject(name, value, ...);
Parameters | ||
---|---|---|
Name | Expected Type | Description |
value | String | The value for the preceding field |
name | String | The field name to add |
Returns an SPDatastashObject object
Any number of name/value pairs can be passed and the values will by applied to the newly-created object. If no values are passed the object will be empty and values can be added using the SPDatastashObject methods.
Method: clear
Removes all objects from the stash and clears any file associations
void clear();
None
Method: deleteobjects
Deletes all the objects in the stash, a single given object, or a subset matching given attribute value criteria
void deleteobjects();
void deleteobjects(object);
void deleteobjects(name, value, ...);
Parameters | ||
---|---|---|
Name | Expected Type | Description |
value | String | The value to compare to each object |
object | SPDatastashObject | The single object to delete |
name | String | The field name to check |
None
Any number of name/value pairs can be passed. Any object matching all the values will be deleted. If a single object is passed, that one object is deleted. If no arguments are provided, all objects in the stash are deleted.
Method: flush
Writes all current objects out to the associated file
void flush();
None
If multiple files were specified when the stash was created, the first one is considered to be the writeable store.
Method: getObjects
Gets all the objects in the stash, or a subset matching given attribute value criteria
SPArray getObjects();
SPArray getObjects(name, value, ...);
Parameters | ||
---|---|---|
Name | Expected Type | Description |
value | String | The value to compare to each object |
name | String | The field name to check |
Returns an SPArray object containing zero or more SPDatasatshObject objects that matched the given criteria
Any number of name/value pairs can be passed. Any object matching all the values will be added to the returned array. If no arguments are provided, all objects in the stash are returned.
Method: getObjectValues
Gets a string containing a list of values associated with objects in the stash
String getObjectValues(fieldName);
String getObjectValues(fieldName, separator);
String getObjectValues(fieldName, separator, name, value, ...);
Parameters | ||
---|---|---|
Name | Expected Type | Description |
value | String | The value to match to the preceding field |
fieldName | String | The field name to extract values from |
name | String | A field name to check for a matching value |
separator | String | A string to insert between successive values in the output |
Returns an String consisting of all the values extracted from the given field of all matching objects, separated by the given separator
E.g. to get a comma-separated list of the values in the "Name" field of all the objects in the stash: getObjectValues("Name", ",");
Method: loadFromFile
Loads the stash from the given file and clears all the file associations of the stash
void loadFromFile(path);
Parameters | ||
---|---|---|
Name | Expected Type | Description |
path | String | The full path name of the file to load from |
None
Method: saveToFile
Writes all current objects out to the given file without changing the file associations of the stash
void saveToFile(path);
Parameters | ||
---|---|---|
Name | Expected Type | Description |
path | String | The full path name of the file to save to |
None