TTMSFNCCloudMyCloudData
Usage
A component that provides seamless access to the myCloudData.net service that allows to create tables with meta data of choice to store data in the cloud. A user can have access to one or more tables. After login, the collection of tables available to the user is returned with GetTables
and accessible via the Tables
collection. A table on myCloudData.net is represented by the class TTMSFNCCloudMyCloudDataTable
. A table has metadata, entities, filters, sort order and shares. The table entities are represented by the class TTMSFNCCloudMyCloudDataEntity
. The shares are represented by the class TTMSFNCCloudMyCloudDataShare
. The metadata for a table is retrieved via Table.GetMetaData
. The entities are retrieved via the Table
.Query
function and the list of shares is retrieved with Table.Shares
. The filter is accessible via the collection Table.Filters
and the sort ordering can be setup via the collection Table.SortOrder
.
Authorization information
Client ID, Client Secret, CallBack URL
TTMSFNCCloudMyCloudDataEntity
The TTMSFNCCloudMyCloudDataEntity
class is the class that wraps an entity (in database
terminology also often referred to as record). The TTMSFNCCloudMyCloudDataEntity
class has following methods & properties:
Properties
Property name | Description |
---|---|
Value[AName: string]: TValue | |
Blob[AName: string]: TTMSFNCCloudMyCloudDataBlob |
Methods
Method name | Description |
---|---|
Update | |
Insert | |
Delete |
To get or set a value for a field within the entity, you can use Value[AName: string]
.
TTMSFNCCloudMyCloudDataEntities
This is the collection of entities retrieved via Table.Query
.
Typical operations on entities are as such:
- Create a new entity in the cloud storage:
- Update an existing entity in the cloud storage:
- Delete an entity permanently from the cloud storage:
TTMSFNCCloudMyCloudDataBlob
The TTMSFNCCloudMyCloudDataBlob
class is a wrapper class for binary data stored in a blob in the cloud service. Note that the blob storage capability is not available for a free account in myCloudData.net but requires a subscription.
The TTMSFNCCloudMyCloudDataBlob
class has following properties and methods:
Properties
Property name | Description |
---|---|
Table: TTMSFNCCloudMyCloudDataTable | Table to which the blob belongs |
Entity: TTMSFNCCloudMyCloudDataEntity | Entity to which the blob belongs |
Field: string | Name of the field holding the blob |
Methods
Method name | Description |
---|---|
LoadFromFile(AFileName: string); | Load data from AFileName into the blob field. |
SaveToFile(AFileName: string); | Get data from the blob field and save it to a file. |
LoadFromStream(AStream: TStream); | Load data from the stream into the blob field. |
SaveToStream(AStream: TStream); | Get data from the blob field and save it to a stream. |
A typical operation to store some binary data into a blob field in a new entity would be:
Example:
var
ent: TTMSFNCCloudMyCloudDataEntity;
begin
blob: TTMSFNCCloudMyCloudDataBlob;
ent := Table.Entities.Add;
blob := ent.Blob['BIN'];
blob.LoadFromFile('mybinfile.bin');
end;
Note that for performance reasons, blobs are returned via the entity only and retrieved from the cloud storage at the time SaveToStream()
or SaveToFile()
is executed.
TTMSFNCCloudMyCloudDataLookupFieldValue
The TTMSFNCCloudMyCloudDataLookupFieldValue
class contains the key and lookup values
associated with a LookupField
.
Properties
Property name | Description |
---|---|
KeyValue: Variant | The key value of the lookupdata |
LookupValue: Variant | The lookup value of the lookupdata |
Tag: integer | Defines a custom related value |
TTMSFNCCloudMyCloudDataLookupFieldValues
This is the collection of lookup field values from a LookupField
.
Properties
Property name | Description |
---|---|
LookupValues[AKey: Variant]: Variant |
TTMSFNCCLoudMyCloudDataLookupField
The TTMSFNCCloudMyCloudDataLookupField
class contains the lookupdata for a LookupField
.
Properties
Property name | Description |
---|---|
LookupField: string | The name of the field in the parent table that the lookup data is associated with |
TableID: Int64 | The ID of the table that contains the lookup data |
LookupFieldValues: TMyCloudDataLookupFieldValues | The list of key and lookup values |
TTMSFNCCloudMyCloudDataLookupFieldList
This is the collection of lookup fields retrieved via Table.GetLookupData
.
Properties
Property name | Description |
---|---|
Field[AFieldName: string]: TTMSFNCCloudMyCloudDataLookupFieldValues | |
List[AFieldName: string]: TStringList |
TTMSFNCCloudMyCloudDataTable
This class represents the table in the cloud storage and is part of the set of tables in the collection Tables
retrieved with GetTables
.
A TTMSFNCCloudMyCloudDataTable
class has following properties and methods:
Properties
Property name | Description |
---|---|
ID: int64 | Read-only property returning the unique identifier of the table |
OwnerID: int64 | Read-only property returning the unique owner identifier of the table |
IsOwner: boolean | Read-only property returns true when the logged in user owns the table |
Name: string | Gets or sets the name of the table |
Permissions: TTMSFNCCloudMyCloudDataPermissions | Permissions the user has on the table. Permissions are: CRUD, i.e. create/read/update/delete |
MetaData: TMyCloudDataMetaData | Access to the metadata of the table via a collection after calling GetMetaData |
Entities: TMyCloudDataEntities | Access to the entities of the table via a collection after calling Query |
Filters: TMyCloudDataFilters | Access to the filter conditions for a query via a collection |
SortOrder: TMyCloudDataSortOrderList | Access to the sort order settings for a query via a collection |
LookupFieldList: TMyCloudDataLookupFieldList | Access to the list of lookup fields via a collection after calling GetLookupData . |
Methods
Method name | Description |
---|---|
GetMetaData: boolean | Retrieves the metadata from a table, stored in MetaData |
SetMetaData: boolean | Updates the metadata of the table on the cloud storage with Table.MetaData |
Query | Simply query for all entities of the table, stored in Entities |
Query(Fields: TStringArray) | Query with specifier of selection of fields to return, stored in Entities |
Query(AFields: TStringList) | Query with specifier of selection of fields to return, stored in Entities |
Share(Email: string; Permissions: TMyCloudDataPermissions) | Share a table with another user defined by email |
RemoveShare(Email: string) | Remove an existing share with another user via email |
Delete | Delete the table from the cloud storage |
GetShares: TTMSFNCCloudMyCloudDataShares | Retrieve the list of email addresses & permissions with who the table was shared |
GetLookupData: Boolean | Retrieves the lookup data from a table, stored in LookupFieldList . It is required that the Table metadata contains valid values for the LookupTable, LookupField and LookupKeyField properties in order to be able to retrieve lookup data |
To perform a simple query, use:
This will fill the Entities
collection with the entities retrieved from the cloud storage.
To filter data, following code can be used:
var
filter: TMSFNCCloudMyCloudDataFilter;
begin
Table.Filters.Clear; // removes all filter conditions
filter := Table.Filters.Add('NAME', coLike, 'Musk', loNone);
Table.Query;
end;
Or alternatively:
var
filter: TMSFNCCloudMyCloudDataFilter;
begin
Table.Filters.Clear; // removes all filter conditions
filter := Table.Filters.Add;
filter.FieldName := 'NAME';
filter.ComparisonOperator := coLike;
filter.Value := 'Musk';
filter.LogicalOperator := loNone;
Table.Query;
end;
ComparisonOperator
can be any of the following values:
coEqual
, coNotEqual
, coLike
, coGreater
, coGreaterOrEqual
, coLess
, coLessOrEqual
, coStartsWith
, coEndsWith
, coNull
, coNotNull
;
The LogicalOperator
that sets the logical operation between two sequential filter conditions can be: loAND
, loOR
, loNone
To specify the sort order for a query, the Table.SortOrder
collection can be used:
Table.SortOrder.Clear;
Table.SortOrder.Add('NAME', soAscending);
Table.SortOrder.Add('COMPANY', soDescending);
Table.Query;
var
sortorder: TTMSFNCCloudMyCloudDataSortOrderItem;
begin
Table.SortOrder.Clear;
sortorder := Table.SortOrder.Add;
sortorder.FieldName := 'NAME';
sortorder.SortOrder := soAscending;
sortorder := Table.SortOrder.Add;
sortorder.FieldName := 'COMPANY';
sortorder.SortOrder := soDescending;
Table.Query;
end;
TTMSFNCCloudMyCloudDataTables
This is the collection of all the tables a user has access to, either because the user owns the table or the table was shared with the user.
TTMSFNCCloudMyCloudDataMetaDataItem
This class holds the information about a single meta data item in the meta data collection of a table. The meta data item class has following properties:
Properties
General Properties
These properties define the behavior of the MetaDataItem
on the myCloudData server as well as in a client application.
Property name | Description |
---|---|
PropertyName: string | Gets or sets the field name |
DataType: TFieldType | Gets or sets the field type. The field type can be any of following value: ftString , ftWideString , ftInt , ftBigInt , ftFloat , ftBlob , ftSmallInt , ftWord , ftBoolean , ftDate , ftDateTime , ftTime |
Data: Boolean | Returns true when the meta data item pertains actual data |
Size: integer | Optionally gets or sets the size of a field (only available for fields of type ftString , ftWideString ) |
Client Properties
These properties can define the appearance of the MetaDataItem
and how it behaves in a client application. These properties have no influence on the behavior of the MetaDataItem
on the myCloudData server.
Property name | Description |
---|---|
LabelText: string | Gets or sets the label text associated with the field |
DefaultValue: string | Gets or sets the default value associated with the field |
Width: integer | Gets or sets the width associated with the field |
Order: integer | Gets or sets the order index associated with the field (relative to the other fields in the table) |
Mask: string | Gets or sets the field content mask |
Minimum: double | Gets or sets the minimum allowed value associated with the field |
Maximum: double | Gets or sets the maximum allowed value associated with the field |
MinimumDate: tdatetime | Gets or sets the minimum allowed date and/or time associated with the field |
MaximumDate: tdatetime | Gets or sets the maximum allowed date and/or time associated with the field |
Visible: Boolean | Gets or sets the visibility associated with the field. Default is true |
Description: string | Gets or sets the description value associated with the field |
Enabled: Boolean | Gets or sets the enabled status associated with the field. Default is true |
Required: Boolean | Gets or sets the required status associated with the field. Default is false |
LookupTable: int64 | Gets or sets the ID of the lookup table associated with the field |
LookupField: string | Gets or sets the lookup value field from the LookupTable associated with the field. The value should be identical to one of the field names of the table defined in LookupTable and should be different from the LookupKeyField value. |
LookupKeyField: string | Gets or sets the lookup key field from the LookupTable associated with the field. The value should be identical to one of the field names of the table defined in LookupTable and value should be different from the LookupField value |
The meta data item is part of the meta data collection TTMSFNCCloudMyCloudDataMetaData
accessible via Table.MetaData
.
Typical operations on the meta data are:
- Retrieval of meta data & list all fields in a listbox
- Creating meta data for a new table
Or alternatively
Table.MetaData.Clear; Table.MetaData.Add('NAME', ftWideString, 50); Table.MetaData.Add('COMPANY', ftWideString, 50); Table.MetaData.Add('BIN', ftBlob); Table.SetMetaData;
var metadata: TTMSFNCCloudMyCloudDataMetaDataItem; begin Table.MetaData.Clear; metadata := Table.MetaData.Add; metadata.PropertyName := 'NAME'; metadata.DataType := ftWideString; metadata.Size := 50; metadata := Table.MetaData.Add; metadata.PropertyName := 'COMPANY'; metadata.DataType := ftWideString; metadata.Size := 50; metadata := Table.MetaData.Add; metadata.PropertyName := 'BIN'; metadata.DataType := ftBlob; Table.SetMetaData; end;
TTMSFNCCloudMyCloudDataShares
To share a table with another myCloudData.net user, call:
This adds a share with usermyfriend@company.com
. Note that it is required that
myfriend@company.com
is recognized as a valid myCloudData.net user. The myCloudData.net API will not send a notification of the share itself. It is the responsibility of the user to do so. Here a share is created with all permissions except the permission to delete entities in the table.
To remove the share at a later time, call:
When the share existed for the user it will be removed. To see with who a table is shared, use:var
shares: TTMSFNCCloudMyCloudDataShares;
begin
shares := Table.GetShares;
for i := 0 to shares.Count - 1 do
begin
listbox.Items.Add(shares[i].Email);
end;
end;
TTMSFNCCloudMyCloudData
TTMSFNCCloudMyCloudData
is the class that wraps the entire access to the myCloudData.net service.
Properties
Property name | Description |
---|---|
TableId: int64 | Gets or sets the unique ID of the table TTMSFNCCloudAdvMyCloudData can work on |
Methods
Table related methods
Method name | Description |
---|---|
GetTables | Retrieves the list of tables and makes these accessible via TAdvMyCloudData.Tables |
TableByName(AName: string) | Retrieves a table based on its name |
TableList | Retrieves a table based on its name |
AddTable(ATable: TTMSFNCCloudMyCloudDataTable) | Creates a new table from an existing TTMSFNCCloudMyCloudDataTable class |
CreateTable(ATableName: string) | Creates a new table with name ATableName and returns an instance to the table |
DeleteTable(AID: int64) | Deletes a table based on its unique ID |
DeleteTable(ATable: TTMSFNCCloudMyCloudDataTable) | Deletes a table based on an existing TMyCloudDataTable class |
UpdateTable(ATable: TTMSFNCCloudMyCloudDataTable) | Updates table info, such as name, permissions based on an existing TMyCloudDataTable class |
ShareTable(ATable: TTMSFNCCloudMyCloudDataTable; AEmail: string; APermissions: string) | Share a table with specific permissions with another myCloudData.net user |
GetTableShares(ATable: TMyCloudDataTable) | Fills the Table.Shares collection with shares found |
Metadata related methods
Method name | Description |
---|---|
GetMetaData | Retrieves the metadata for the table specified by TTMSFNCCloudMyCloudData.TableId |
AddMetaData(AMetaData: TTMSFNCCloudMyCloudDataMetaDataItem ) |
Sets the metadata for table specified by TTMSFNCCloudAdvMyCloudData.TableId |
UpdateMetaData(AOldFieldName, ANewFieldName: string; ADataType: TFieldType = ftUnknown; ASize: integer = -1) | Modifies the meta data of a single field (specified by ANewFieldName and limited to to the field name, field datatype and field size) for a table specified by TTMSFNCCloudAdvMyCloudData.TableId |
UpdateMetaData(AMetaData: TTMSFNCCloudMyCloudDataMetaDataitem) | Modifies all the meta data of a single field (specified by AMetaData) for a table specified by TTMSFNCCloudAdvMyCloudData.TableId . |
DeleteMetaData(APropertyName: string) | Delete a field from the meta data for a table specified by TTMSFNCCloudAdvMyCloudData.TableId |
Entity related methods
Method name | Description |
---|---|
Insert(AValues: TStringList): TTMSFNCCloudDatastoreEntity | Inserts entity values via a stringlist |
Query | Retrieves entities for a table specified by TTMSFNCCloudAdvMyCloudData.TableId |
Query(AFields: TStringList) | Retrieves entities with fields limitied to the specified list for a table specified by TTMSFNCCloudAdvMyCloudData.TableId |
Query(AFields: TStringList; AFilters: TTMSFNCCloudMyCloudDataFilters) | Retrieves entities with filter conditions |
Query(AFields: TStringList; ASortOrder: TTMSFNCCloudMyCloudDataSortOrderList) | Retrieves entities with sort order specified |
Query(AFields: TStringList; AFilters: TTMSFNCCloudMyCloudDataFilters; ASortOrder: TTMSFNCCloudMyCloudDataSortOrderList) | Retrieves entities with filter conditions and sort order specified |
Delete(AID: string) | Delete an entity with ID from a table specified by TTMSFNCCloudAdvMyCloudData.TableId |
Delete(AIDList: TStringList) | Delete multiple entities from a table specified by TTMSFNCCloudAdvMyCloudData.TableId . Only entities with an ID specified in AIDList will be deleted. |
DeleteAll | Delete all entities from a table specified by TTMSFNCCloudAdvMyCloudData.TableId |
Update(AEntity: TDataStoreEntity) | Update the entity in a table specified by TTMSFNCCloudAdvMyCloudData.TableId |
Update (AIDList, AFieldValues: TStringList) | Update multiple entities in a table specified by TTMSFNCCloudAdvMyCloudData.TableId . Only entities with an ID specified in AIDList will be updated. Only fields specified in AFieldValues will be updated. See example |
UpdateAll(AFieldValues: TStringList) | Update all entities in a table specified by TTMSFNCCloudMyCloudData.TableId . Only fields specified in AFieldValues will be updated. |
Download(ATableID, AEntityId: Int64; AFieldName: string; const TargetFile: string) | Download a blob to a file value from a specific entity in a specific table and fieldname |
Download(ATableID, AEntityId: Int64; AFieldName: string; AStream: TStream) | Download a blob value in a stream from a specific entity in a specific table and fieldname |
Upload(ATableID, AEntityId: Int64; AFieldName: string; FileName: string) | Upload a file to a blob field from a specific entity in a specific table and fieldname |
Upload(ATableID, AEntityId: Int64; AFieldName: string; AStream: TStream) | Upload a stream to a blob field from a specific entity in a specific table and fieldname |
Example
var
slIDs, slFields: TStringList;
begin
slIDs := TStringList.Create;
slIDs.Add('1');
slIDs.Add('2');
slFields := TStringList.Create;
slFields.CommaText := 'FieldName=FieldValue';
AdvMyCloudData1.Update(slIDs, slFields);
slIDs.Free;
slFields.Free;
Users related methods
Method name | Description |
---|---|
GetUser | Gets information about the currently authenticated user. Fills the User properties. |
GetUsers | Get list of users, for non-admin users, this retrieves the logged in user. Fills the Users collection property |
AddUser(AUser: TMyCloudDataUser) | Available for admin level users only |
DeleteUser(AID: int64) | Available for admin level users only |
Additional properties
Property name | Description |
---|---|
User: TTMSFNCCloudMyCloudDataUser | Contains information about the currently authenticated user |
Users: TTMSFNCCloudMyCloudDataUsers | Collection of users, filled by the GetUsers method |
Tables: TTMSFNCCloudMyCloudDataTables | Collection of users, filled by the GetTables method |
PageIndex: integer | When > 0 , this specifies the page of entities to retrieve for the Query() methods |
PageSize: integer | When > 0 , specifies the maximum number of entities to return for the Query() methods. The last page is retrieved when number of entities is smaller than PageSize . |