StorageCollection
Class that holds the StorageCollection resource. StorageCollections contain Storage objects
which can be used to persist data in Oracle Mobile Hub.
- Source:
Methods
contains(id) → {Promise.<NetworkResponse>}
Is object exists in the collection.
Checks the service if a StorageObject with the given ID exists in the collection.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | The ID of the StorageObject to check. |
- Source:
Returns:
- Type
- Promise.<NetworkResponse>
deleteObject(id) → {Promise.<NetworkResponse>}
Delete object.
Deletes a StorageObject from a collection.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | The ID of the StorageObject to delete. |
- Source:
Returns:
- Type
- Promise.<NetworkResponse>
getData() → {object}
Get data.
Returns data for current storage collection.
- Source:
Returns:
storage object data for current storage collection.
- Type
- object
getDescription() → {String}
Get description.
The description of the StorageCollection.
- Source:
Returns:
- Type
- String
getObject(id, objectType) → {Promise.<(StorageObject|NetworkResponse)>}
Returns a StorageObject given its ID. The contents of the object will be downloaded lazily.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The ID of the Storage Object to return. |
objectType |
string | responseType for the XMLHttpRequest Object. Default response type if not defined is json. Ths parameter can be one of the types: 'json', 'blob', 'arraybuffer', 'document', 'text'. |
- Source:
Returns:
- Type
- Promise.<(StorageObject|NetworkResponse)>
Example
StorageCollection.getObject('00e39862-9652-458b-9a82-d1a66cf1a0c7', mcs.RESPONSE_TYPES.BLOB).then(
function(storageObject){
},
function(networkResponse){
});
getObjects(offset, limit, allObjects) → {Promise.<(Array.<StorageObject>|NetworkResponse)>}
Get objects.
Returns a list of StorageObjects from the collection starting from the offset and up to the limit.
The service may return fewer objects.
1. If the collection is a shared collection, then it returns all the objects.
2. If the collection is a user-isolated collection and allObjects is false, then it returns the objects which belong to the current user.
3. If the collection is user-isolated collection, and allObjects is true, then it returns all the objects in the collection.
The objects might belong to other users. And the current user MUST have READ_ALL or READ_WRITE_ALL permission.
1. If the collection is a shared collection, then it returns all the objects.
2. If the collection is a user-isolated collection and allObjects is false, then it returns the objects which belong to the current user.
3. If the collection is user-isolated collection, and allObjects is true, then it returns all the objects in the collection.
The objects might belong to other users. And the current user MUST have READ_ALL or READ_WRITE_ALL permission.
Parameters:
Name | Type | Description |
---|---|---|
offset |
Number | The offset at which to start. Must be greater than 0. |
limit |
Number | The max number of StorageObjects to return. Must be non-negative. |
allObjects |
Boolean | whether to return all the objects in the list. |
- Source:
Returns:
- Type
- Promise.<(Array.<StorageObject>|NetworkResponse)>
getStorage() → {Storage}
Get storage.
Returns storage object for current storage collection.
- Source:
Returns:
storage object data for current storage collection.
- Type
- Storage
loadMetadata() → {Promise.<(StorageCollection|NetworkResponse)>}
Load metadata.
Load collection metadata
- Source:
Returns:
- Type
- Promise.<(StorageCollection|NetworkResponse)>
postObject(storageObject) → {Promise.<NetworkResponse>}
Post object.
Creates a new StorageObject in the collection.
Parameters:
Name | Type | Description |
---|---|---|
storageObject |
StorageObject | The StorageObject to create. |
- Source:
Returns:
- Type
- Promise.<NetworkResponse>
Example
storageObject:
{
"id": " 213ddbac-ccb2-4a53-ad48-b4588244tc4c", // A service generated ID for the StorageObject.
The ID is unique in the StorageCollection.
"name" : "JSText.txt", // A user provided name for the StorageObject.
A StorageCollection may have multiple StorageObjects with the same name.
"contentLength": 798", // The length of data content in bytes stored in the StorageObject.
"contentType" : "text/plain ", // The media-type associated with the StorageObject.
"createdBy" : "DwainDRob", // The name of the user who created the StorageObject
"createdOn": "Sat, 17 Oct 2015 10:33:12", // Server generated timestamp when the StorageObject was created.
"modifiedBy": "DwainDRob", // The name of the user who last updated the StorageObject.
"modifiedOn": "Sat, 17 Oct 2015 10:33:12" // Server generated timestamp when the StorageObject was last updated.
}
putObject(storageObject) → {Promise.<(NetworkStorageObject|NetworkResponse)>}
Put object.
Updates an existing StorageObject in the collection.
Parameters:
Name | Type | Description |
---|---|---|
storageObject |
StorageObject | The StorageObject to update. |
- Source:
Returns:
- Type
- Promise.<(NetworkStorageObject|NetworkResponse)>