SQLDatabaseProvider
open class SQLDatabaseProvider : ObjectBase, DataServiceProvider
An implementation of DataServiceProvider
using a SQL database.
A remote OData service is not required in order to use this provider.
The underlying database software is SQLite (SQLCipher).
-
Specify an encryption key to be used when the provider creates or opens a database.
Declaration
Swift
final public var encryptionKey: String?
-
Should this provider automatically generate primary keys? Defaults to
true
. If the provider doesn’t generate keys, then the client will have to provide them.See also
useClientProvidedKeys
.Declaration
Swift
final public var autoGenerateKeys: Bool
-
Should this provider automatically bind entities in
createEntity
orupdateEntity
, if bound entities are provided by the client. Defaults totrue
.Declaration
Swift
final public var autoBindEntities: Bool
-
Should this provider automatically unbind entities in
createEntity
orupdateEntity
, if unbound entities are provided by the client. Defaults totrue
.Declaration
Swift
final public var autoUnbindEntities: Bool
-
Should this provider automatically create parents in
createEntity
(“deep insert” calls), if nested parents are provided by the client. Defaults totrue
.Declaration
Swift
final public var autoCreateParents: Bool
-
Should this provider automatically create children in
createEntity
(“deep insert” calls), if nested children are provided by the client. Defaults totrue
.Declaration
Swift
final public var autoCreateChildren: Bool
-
Should this provider automatically delete children in
deleteEntity
(“on delete” actions), if specified with OnDelete in the service metadata. Defaults totrue
.Declaration
Swift
final public var autoDeleteChildren: Bool
-
Should this provider automatically expand itemns in
executeQuery
, if requested in the client’s query. Defaults totrue
.Declaration
Swift
final public var autoExpandItems: Bool
-
Should entities be reselected after
createEntity
(SQL insert)? Defaults totrue
. This ensures that database-generated column values will be available in theentity
parameter. Setting this property tofalse
will result in better createEntity performance, but database-generated values will not be available in theentity
parameter. Database-generated primary keys (seeautoGenerateKeys
) will still be available without settingselectAfterCreate
as they are obtained without reselecting the entity. Note: ifenableRowVersioning
istrue
andmaintainVersionColumns
isfalse
, then entities will be automatically reselected aftercreateEntity
even ifselectAfterCreate
isfalse
.Declaration
Swift
final public var selectAfterCreate: Bool
-
Should entities be reselected after
updateEntity
(SQL update)? Defaults totrue
. This ensures that database-generated column values will be available in theentity
parameter. Setting this property tofalse
will result in betterupdateEntity
performance, but database-generated values will not be available in theentity
parameter. Database-generated primary keys (seeautoGenerateKeys
) will still be available without settingselectAfterUpdate
as they are obtained without reselecting the entity. Note: ifenableRowVersioning
istrue
andmaintainVersionColumns
isfalse
, then entities will be automatically reselected aftercreateEntity
even ifselectAfterUpdate
isfalse
.Declaration
Swift
final public var selectAfterUpdate: Bool
-
Should this provider use key tracking for determining when “delete” is required in delta responses? Defaults to
false
.Declaration
Swift
final public var enableKeyTracking: Bool
-
Should this provider be enabled for row versioning? Defaults to
false
. When row versioning is enabled, each table row contains a version number that is incremented by one for each update. All updates apply optimistic concurrency control to check that the pre-update row version matches the version known to the client.Declaration
Swift
final public var enableRowVersioning: Bool
-
Should this provider maintain the row version column? Defaults to
false
. Only applicable ifenableRowVersioning
istrue
. By default, a database is assumed to maintain the row version itself (e.g. using triggers).See also
StorageOptions.rowVersionColumn
.Declaration
Swift
final public var maintainVersionColumns: Bool
-
Should complex properties be flattened into separate columns for database storage? Defaults to
false
.Declaration
Swift
final public var flattenComplexProperties: Bool
-
Should the provider generate
foreign key
constraints when it creates database tables? Defaults tofalse
. Foreign key constraints ensure that related rows do in fact exist. Foreign key constraints should not be used for tables with inline isDeleted / lastModified columns (for change tracking).Declaration
Swift
final public var generateForeignKeyConstraints: Bool
-
Should the provider generate
unique
constraints when it creates database tables? Defaults tofalse
. Unique constraints ensure the integrity of one-to-one relationships (i.e. that we do not have many related rows). Unique constraints should not be used for tables with inline isDeleted / lastModified columns (for change tracking).Declaration
Swift
final public var generateUniqueConstraints: Bool
-
Batch size to be used for statement batching with this provider. Defaults to
100
. Set this to zero to disable statement batching.Declaration
Swift
final public var statementBatchSize: Int
-
Cache size to be used for statement caching with this provider (per connection). Defaults to
100
. Set this to zero to disable statement caching.Declaration
Swift
final public var statementCacheSize: Int
-
Is this provider permitted to modify the database schema, e.g. by adding required tables? Defaults to
true
. If not enabled, then schema changes will need to be managed by the database administrator.Declaration
Swift
final public var canModifySchema: Bool
-
Is this database a cache (staging) database for a backend system? Defaults to
false
.Declaration
Swift
final public var isCacheDatabase: Bool
-
Is this provider used for data metrics?
Declaration
Swift
final public var isMetricProvider: Bool
-
Should
executeQuery
with non-nullDataQuery.searchExpression
use database-level implementation of full-text searching. Defaults tofalse
. Currently this is only supported for SAP HANA.Declaration
Swift
final public var useDatabaseTextSearch: Bool
-
Should
createEntity
use client-provided keys (when available), in preference to server-generated keys? Defaults tofalse
.Declaration
Swift
final public var useClientProvidedKeys: Bool
-
Constructs a SQL database provider which will execute OData requests against a SQL database. A remote OData service is not required in order to use this provider. The
serviceName
is used for logging. The optionaldatabaseURL
specifies a database URL for SQLite (SQLCipher), e.g."sqlite:~/my-database.db"
. If not specified, theserviceName
will be used to construct a default URL.Declaration
Swift
public init(serviceName: String, databaseURL: String? = nil)
Parameters
serviceName
Service name.
databaseURL
Database URL.
-
Apply the changes from a change set to the target system.
See also
processBatch
.Declaration
Swift
open func applyChanges(_ changes: ChangeSet, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
changes
The change set.
headers
Optional request-specific headers.
options
Optional request-specific options.
-
Begin a new transaction, or begin a nested transaction if a transaction is already active for this provider in the current thread.
Declaration
Swift
open func beginTransaction() throws
-
This function may be used in the implementation of entity binding calls, e.g. by
EntityValue.bindEntity
. It relies on the existence of appropriate referential constraints in the service metadata, or an appropriately set join entity set.Declaration
Swift
open func bindEntities(entity: EntityValue, bindingProperty: Property? = nil, afterCreate: Bool = false, afterUpdate: Bool = false) throws
Parameters
entity
Source entity, which may contain inline bindings for the binding property.
bindingProperty
Binding property. If
nil
, then all of the source’s navigation properties are considered.afterCreate
Is this call for binding after createEntity has created
entity
? Defaults to false.afterUpdate
Is this call for binding after updateEntity has updated
entity
? Defaults to false. -
This function may be used in the implementation of entity binding calls after the main create action of
createEntity
. It relies on the existence of appropriate referential constraints in the service metadata.Declaration
Swift
open func bindEntitiesAfterCreate(entity: EntityValue, bindingProperty: Property? = nil) throws
Parameters
entity
Source entity, which may contain inline bindings for the binding property.
bindingProperty
Binding property. If
nil
, then all of the source’s navigation properties are considered. -
This function may be used in the implementation of entity binding calls after the main update action of
updateEntity
. It relies on the existence of appropriate referential constraints in the service metadata.Declaration
Swift
open func bindEntitiesAfterUpdate(entity: EntityValue, bindingProperty: Property? = nil) throws
Parameters
entity
Source entity, which may contain inline bindings for the binding property.
bindingProperty
Binding property. If
nil
, then all of the source’s navigation properties are considered. -
If the current thread is connected to this database, then disconnect it.
Declaration
Swift
open func closeConnection() throws
-
Commit the current transaction. If the current transaction is a nested transaction, then decrease the nesting level.
Declaration
Swift
open func commit() throws
-
This function may be used in the implementation of “deep insert” calls, e.g. by
createEntity
. This function will execute “deep insert” if the parent-child entity relationship is fulfilled through join set.Declaration
Swift
open func createChildren(entity: EntityValue, childProperty: Property? = nil) throws
Parameters
entity
Parent entity, which may contain inline children for the child property.
childProperty
Child property. If
nil
, then all of the parent’s navigation properties are considered. -
Create an entity in the target system. Automatically calls
CsdlDocument.resolveEntity
to ensure thatEntityValue.entitySet
is available.Throws
DataServiceException
if the entity set hasn’t been explicitly provided before callingcreateEntity
and there isn’t a unique entity set for the entity type.See also
EntityValue.ofType
,EntityValue.inSet
.Declaration
Swift
open func createEntity(_ entity: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Entity to be created.
headers
Request-specific headers.
options
Request-specific options.
-
Call
createEntity
but catch any exception it throws (non-logged) and return it.Declaration
Swift
open func createEntityReturningError(entity: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> Error?
Parameters
entity
Entity to be created.
headers
Request-specific headers.
options
Request-specific options.
Return Value
Caught error, if any. (The error will not be logged).
-
Define a database index for an entity set. Actual creation of the index is deferred until the first database connection is opened (explicitly or implicitly).
See also
EntitySet.indexes
.Declaration
Swift
open func createIndex(_ entitySet: EntitySet, _ item: PropertyPath, _ items: PropertyPath...)
-
Create a link from a source entity to a target entity.
Declaration
Swift
open func createLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
from
Source entity for the link to be created.
property
Source navigation property for the link to be created.
to
Target entity for the link to be created.
headers
Request-specific headers.
options
Request-specific options.
-
Default implementation of ‘createLink’ using foreign keys from referential constraints in service metadata.
Declaration
Swift
open func createLinkUsingForeignKeys(source: EntityValue, sourceProperty: Property, target: EntityValue) throws
Parameters
source
Source entity for the link to be created.
sourceProperty
Source navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.
target
Target entity for the link to be created.
-
Create a media entity with the specified content in the target system. If the
entity
has non-stream structural properties in addition to the key properties and media content, such aslabel
in the examples below, then this function will send two requests to the server: a first request to upload (POST) the media stream, and a second request (PATCH/PUT) to update the non-stream properties. It is not currently supported to make these two calls atomic. Caution: Having too many threads simultaneously creating streams may result in out-of-memory conditions on memory-constrained devices.Declaration
Swift
open func createMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Entity to be created.
content
Initial content. Must be a
ByteStream
orCharStream
. Will be closed before this function returns.headers
Request-specific headers.
options
Request-specific options.
-
This function may be used in the implementation of “deep insert” calls, e.g. by
createEntity
. This function will not execute “deep insert” if the parent-child entity relationship is fulfilled through join set.Declaration
Swift
open func createParents(entity: EntityValue, parentProperty: Property? = nil) throws
Parameters
entity
Child entity, which may contain inline parent(s) via the parent property.
parentProperty
Child property. If
nil
, then all of the parent’s navigation properties are considered. -
Create (if non-existent) the database schema artifacts (e.g. tables) for this provider.
Declaration
Swift
open func createSchema() throws
-
Create (if non-existent) the database schema artifacts (e.g. tables) for this provider. If creation fails, then retry (potentially forever) with a one minute delay between retries.
Declaration
Swift
open func createSchemaWithRetryLoop() throws
-
Declaration
Swift
open func currentLDT() throws -> GlobalDateTime
Return Value
the current local date/time according to the database server.
-
Declaration
Swift
open func currentUTC() throws -> GlobalDateTime
Return Value
the current global time (UTC) according to the database server.
-
Should all connections (opening/closing) to this SQL database service be logged at debug level? Defaults to
false
.Declaration
Swift
open var debugConnections: Bool { get set }
-
Execute query to delete data from the target system.
Declaration
Swift
open func deleteByQuery(_ query: DataQuery, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
query
Data query specifying the information to be deleted.
headers
Request-specific headers.
options
Request-specific options.
-
This function may be used in the implementation of “on delete” actions, e.g. by
deleteEntity
.Declaration
Swift
open func deleteChildren(entity: EntityValue, childProperty: Property? = nil) throws
Parameters
entity
Parent entity.
childProperty
Child property. If
nil
, then all of the parent’s navigation properties are considered. -
Delete an entity from the target system.
Declaration
Swift
open func deleteEntity(_ entity: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Entity to be deleted.
headers
Request-specific headers.
options
Request-specific options.
-
Call
deleteEntity
but catch any exception it throws (non-logged) and return it.Declaration
Swift
open func deleteEntityReturningError(entity: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> Error?
Parameters
entity
Entity to be deleted.
headers
Request-specific headers.
options
Request-specific options.
Return Value
Caught error, if any. (The error will not be logged).
-
Delete a link from a source entity to a target entity.
Declaration
Swift
open func deleteLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
from
Source entity for the link to be deleted.
property
Source navigation property for the link to be deleted.
to
Target entity for the link to be deleted.
headers
Request-specific headers.
options
Request-specific options.
-
Default implementation of ‘deleteLink’ using foreign keys from referential constraints in service metadata.
Declaration
Swift
open func deleteLinkUsingForeignKeys(source: EntityValue, sourceProperty: Property, target: EntityValue) throws
Parameters
source
Source entity for the link to be created.
sourceProperty
Source navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.
target
Target entity for the link to be created.
-
Delete (if existing) the database schema artifacts (e.g. tables) for this provider.
Declaration
Swift
open func deleteSchema() throws
-
Delete the content of a stream property from the target system.
Declaration
Swift
open func deleteStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Entity containing the stream property whose content is to be deleted.
headers
Request-specific headers.
options
Request-specific options.
link
Stream link for the stream to be deleted.
-
Obtain a stream for downloading the content of a media entity from the target system. Caution: streams are often used for large content that may not fit (all at once) in available application memory. Having too many threads simultaneously downloading streams, or using
ByteStream.readAndClose
, may result in out-of-memory conditions on memory-constrained devices.Declaration
Swift
open func downloadMedia(entity: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> ByteStream
Parameters
entity
Entity whose content is to be downloaded.
headers
Request-specific headers.
options
Request-specific options.
Return Value
A stream for downloading the content of a media entity. This must be closed by the caller, or else a resource leak may occur.
-
Obtain a stream for downloading the content of a stream property from the target system. Caution: streams are often used for large content that may not fit (all at once) in available application memory. Having too many threads simultaneously downloading streams, or using
ByteStream.readAndClose
, may result in out-of-memory conditions on memory-constrained devices.See also
Property.getStreamLink
.Declaration
Swift
open func downloadStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> ByteStream
Parameters
entity
Entity containing the stream property whose content is to be downloaded.
link
Stream link for the stream to be downloaded.
headers
Request-specific headers.
options
Request-specific options.
Return Value
A stream for downloading the content of a stream property. This must be closed by the caller, or else a resource leak may occur.
-
If the current thread’s connection has batched statements, execute them now.
Declaration
Swift
open func executeBatch() throws
-
Execute a data method (action or function) in the target system. Actions may have backend side-effects. Functions should not have backend side-effects.
Throws
DataServiceException
orDataNetworkException
if an error occurs during action invocation.Declaration
Swift
open func executeMethod(_ method: DataMethod, parameters: ParameterList, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> DataValue?
Parameters
method
Data method.
parameters
Method parameters.
headers
Request-specific headers.
options
Request-specific options.
Return Value
The method result, or
nil
if the method has no result. -
Execute a data query to get data from the target system.
Declaration
Swift
open func executeQuery(_ query: DataQuery, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> QueryResult
Parameters
query
Data query specifying the information to be returned.
headers
Request-specific headers.
options
Request-specific options.
Return Value
The query result.
-
Override this function to implement item expansion for this service. If not overridden, referential constraints are used to implement automatic expansion.
Declaration
Swift
open func expandItem(entity: EntityValue, item: ExpandItem) throws
Parameters
entity
Entity whose item is to be expanded.
item
Item to be expanded.
-
If
query
contains anyDataQuery.expandItems
, apply them toresult
.Parameters
query
Query which may optionally contain expand items.
result
Query result, to which item expansion may be applied (if not
nil
, the result should be an entity value or entity list). -
Fetch latest service metadata and return it, but don’t change the
metadata
property.See also
loadMetadata
.Declaration
Swift
open func fetchMetadata(headers: HTTPHeaders, options: RequestOptions) throws -> CSDLDocument
Parameters
headers
Optional request-specific headers.
options
Optional request-specific options.
Return Value
Latest service metadata.
-
Has service metadata been loaded.
See also
loadMetadata
.Declaration
Swift
open var hasMetadata: Bool { get }
-
Declaration
Swift
open func inTransaction() throws -> Bool
Return Value
true
if a transaction is currently active in the current thread for this provider. -
Reload an existing entity from the target system.
Example using proxy classes
open func loadEntityExample() throws -> Void { let service = self.service let customer = Customer() customer.customerID = "ALFKI" try service.loadEntity(customer) self.showCustomer(customer) }
Example using dynamic API
open func loadEntityExample() throws -> Void { let service = self.service let customersEntitySet = service.entitySet(withName: "Customers") let customerEntityType = customersEntitySet.entityType let customerIDProperty = customerEntityType.property(withName: "CustomerID") let customer = EntityValue.ofType(customerEntityType) customerIDProperty.setStringValue(in: customer, to: "ALFKI") try service.loadEntity(customer) self.showCustomer(customer) }
Declaration
Swift
open func loadEntity(_ entity: EntityValue, query: DataQuery? = nil, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Previously loaded entity, whose properties will be modified to reflect the loaded state.
query
Optional data query, to specify loading criteria (especially for navigation properties).
headers
Optional request-specific headers.
options
Optional request-specific options.
-
Load service metadata (if not already loaded).
Declaration
Swift
open func loadMetadata(headers: HTTPHeaders, options: RequestOptions) throws
Parameters
headers
Optional request-specific headers.
options
Optional request-specific options.
-
Load the value of a property into an existing entity. This can be applied to both structural and navigation properties.
See also
DataQuery.load
.Declaration
Swift
open func loadProperty(_ property: Property, into: EntityValue, query: DataQuery? = nil) throws
Parameters
property
Property to load.
into
Existing entity.
query
Optional data query, to specify loading criteria (especially for navigation properties).
-
Should all database exceptions be logged?
Declaration
Swift
@inline(__always) public final var logExceptions: Bool { get set }
-
Service metadata.
See also
loadMetadata
.Declaration
Swift
open var metadata: CSDLDocument { get set }
-
If the current thread is not connected to this database, then connect it.
Declaration
Swift
open func openConnection() throws
-
Open the database schema for this provider. Ensures that database connectivity is available and that (in principle) database operations can proceed.
Declaration
Swift
open func openSchema() throws
-
Open the database schema for this provider. Ensures that database connectivity is available and that (in principle) database operations can proceed. If opening fails, then retry (potentially forever) with a one minute delay between retries.
Declaration
Swift
open func openSchemaWithRetryLoop() throws
-
Ping the server.
Declaration
Swift
open func pingServer(headers: HTTPHeaders, options: RequestOptions) throws
Parameters
headers
Optional request-specific headers.
options
Optional request-specific options.
-
Execute
work
within a transaction.Declaration
Swift
open func prepareData(work: @escaping () throws -> Void) throws
Parameters
work
Work to be executed within a transaction.
-
Execute a request batch in the target system.
Declaration
Swift
open func processBatch(_ batch: RequestBatch, headers: HTTPHeaders, options: RequestOptions) throws
Parameters
batch
The request batch.
headers
Request-specific headers.
options
Request-specific options.
-
Rollback the current transaction. If the current transaction is a nested transaction, then decrease the nesting level, and mark the outermost (non-nested) transaction for eventual rollback.
Declaration
Swift
open func rollback() throws
-
Declaration
Swift
open func schemaExists() throws -> Bool
Return Value
true
if the database schema artifacts (e.g. tables) exist for this provider. -
Declaration
Swift
open func selectEntity(_ entity: EntityValue) throws -> EntityValue
Parameters
entity
Entity value.
Return Value
Newly loaded copy of
entity
with all structural properties selected. -
Service name.
Declaration
Swift
open var serviceName: String { get }
-
Register a callback handler which will be used for loading initial data into the database.
Declaration
Swift
open func setInitialDataLoader(_ loader: @escaping () -> Void)
Parameters
loader
Initial data Loader.
-
Options for database storage.
Declaration
Swift
@inline(__always) public final var storageOptions: StorageOptions { get }
-
See also
executeMethod
.Declaration
Swift
open func storedProcedure(name: String) -> DataMethod
Parameters
name
Stored procedure name.
Return Value
a data method for use in the execution of a database stored procedure.
-
Should all connections (opening/closing) to this SQL database service be logged at trace level? Defaults to
false
.Declaration
Swift
open var traceConnections: Bool { get set }
-
Should all requests for this SQL database service be traced? Defaults to
false
.Declaration
Swift
@inline(__always) public final var traceRequests: Bool { get set }
-
Should all rollbacks for this SQL database service be traced (with a stack trace)? Defaults to
false
.Declaration
Swift
@inline(__always) public final var traceRollbacks: Bool { get set }
-
If
traceRequests
is alsotrue
, should all requests for this SQL database be traced with data? Defaults tofalse
. Note that care must be taken when enabling tracing with data, as the resulting log files may contain sensitive information. On the other hand, tracing with data may sometimes be invaluable for troubleshooting purposes.Declaration
Swift
@inline(__always) public final var traceWithData: Bool { get set }
-
Perform some work within a database transaction. If a transaction is already active, then the work will be performed within a nested transaction.
Declaration
Swift
open func transaction(work: @escaping () throws -> Void) throws
Parameters
work
Work to be executed within a transaction.
-
This function may be used in the implementation of entity binding calls, e.g. by
EntityValue.unbindEntity
. It relies on the existence of appropriate referential constraints in the service metadata.Declaration
Swift
open func unbindEntities(entity: EntityValue, bindingProperty: Property? = nil) throws
Parameters
entity
Source entity, which may contain inline bindings for the binding property.
bindingProperty
Binding property. If
nil
, then all of the source’s navigation properties are considered. -
Unload service metadata (if previously loaded).
Declaration
Swift
open func unloadMetadata() throws
-
Update an entity in the target system.
Declaration
Swift
open func updateEntity(_ entity: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Entity to be updated.
headers
Request-specific headers.
options
Request-specific options.
-
Call
updateEntity
but catch any exception it throws (non-logged) and return it.Declaration
Swift
open func updateEntityReturningError(entity: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> Error?
Parameters
entity
Entity to be updated.
headers
Request-specific headers.
options
Request-specific options.
Return Value
Caught error, if any. (The error will not be logged).
-
Update a link from a source entity to a target entity.
Declaration
Swift
open func updateLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
from
Source entity for the link to be updated.
property
Source navigation property for the link to be updated. This must be a one-to-one navigation property.
to
Target entity for the link to be updated.
headers
Request-specific headers.
options
Request-specific options.
-
Default implementation of ‘updateLink’ using foreign keys from referential constraints in service metadata.
Declaration
Swift
open func updateLinkUsingForeignKeys(source: EntityValue, sourceProperty: Property, target: EntityValue) throws
Parameters
source
Source entity for the link to be created.
sourceProperty
Source navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.
target
Target entity for the link to be created.
-
Upload content for a media entity to the target system Caution: Having too many threads simultaneously uploading streams may result in out-of-memory conditions on memory-constrained devices. Note: this function cannot be used to create a media entity. See
DataService.createMedia
.Declaration
Swift
open func uploadMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Entity whose content is to be uploaded.
content
Upload stream content. Will be closed before this function returns.
headers
Request-specific headers.
options
Request-specific options.
-
Upload content for a stream property to the target system. Caution: Having too many threads simultaneously uploading streams may result in out-of-memory conditions on memory-constrained devices.
See also
Property.getStreamLink
.Declaration
Swift
open func uploadStream(entity: EntityValue, link: StreamLink, content: StreamBase, headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws
Parameters
entity
Entity containing the stream property whose content is to be uploaded.
link
Stream link for the stream to be uploaded.
content
Upload stream content. Will be closed before this function returns.
headers
Request-specific headers.
options
Request-specific options.