SQLDatabaseProvider
open class SQLDatabaseProvider : ObjectBase, DataServiceProvider, @unchecked Sendable
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
createEntityorupdateEntity, if bound entities are provided by the client. Defaults totrue.Declaration
Swift
final public var autoBindEntities: Bool -
Should this provider automatically unbind entities in
createEntityorupdateEntity, 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 items 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 theentityparameter. Setting this property tofalsewill result in better createEntity performance, but database-generated values will not be available in theentityparameter. Database-generated primary keys (seeautoGenerateKeys) will still be available without settingselectAfterCreateas they are obtained without reselecting the entity. Note: ifenableRowVersioningistrueandmaintainVersionColumnsisfalse, then entities will be automatically reselected aftercreateEntityeven ifselectAfterCreateisfalse.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 theentityparameter. Setting this property tofalsewill result in betterupdateEntityperformance, but database-generated values will not be available in theentityparameter. Database-generated primary keys (seeautoGenerateKeys) will still be available without settingselectAfterUpdateas they are obtained without reselecting the entity. Note: ifenableRowVersioningistrueandmaintainVersionColumnsisfalse, then entities will be automatically reselected aftercreateEntityeven ifselectAfterUpdateisfalse.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 ifenableRowVersioningistrue. 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 keyconstraints 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
uniqueconstraints 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
executeQuerywith non-nullDataQuery.searchExpressionuse 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
createEntityuse 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
serviceNameis used for logging. The optionaldatabaseURLspecifies a database URL for SQLite (SQLCipher), e.g."sqlite:~/my-database.db". If not specified, theserviceNamewill be used to construct a default URL.Declaration
Swift
public init(serviceName: String, databaseURL: String? = nil)Parameters
serviceNameService name.
databaseURLDatabase 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) throwsParameters
changesThe change set.
headersOptional request-specific headers.
optionsOptional 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) throwsParameters
entitySource entity, which may contain inline bindings for the binding property.
bindingPropertyBinding property. If
nil, then all of the source’s navigation properties are considered.afterCreateIs this call for binding after createEntity has created
entity? Defaults to false.afterUpdateIs 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) throwsParameters
entitySource entity, which may contain inline bindings for the binding property.
bindingPropertyBinding 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) throwsParameters
entitySource entity, which may contain inline bindings for the binding property.
bindingPropertyBinding 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) throwsParameters
entityParent entity, which may contain inline children for the child property.
childPropertyChild property. If
nil, then all of the parent’s navigation properties are considered. -
Create an entity in the target system. Automatically calls
CsdlDocument.resolveEntityto ensure thatEntityValue.entitySetis available.Throws
DataServiceExceptionif the entity set hasn’t been explicitly provided before callingcreateEntityand 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) throwsParameters
entityEntity to be created.
headersRequest-specific headers.
optionsRequest-specific options.
-
Call
createEntitybut 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
entityEntity to be created.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
fromSource entity for the link to be created.
propertySource navigation property for the link to be created.
toTarget entity for the link to be created.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
sourceSource entity for the link to be created.
sourcePropertySource navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.
targetTarget entity for the link to be created.
-
Create a media entity with the specified content in the target system. If the
entityhas non-stream structural properties in addition to the key properties and media content, such aslabelin 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) throwsParameters
entityEntity to be created.
contentInitial content. Must be a
ByteStreamorCharStream. Will be closed before this function returns.headersRequest-specific headers.
optionsRequest-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) throwsParameters
entityChild entity, which may contain inline parent(s) via the parent property.
parentPropertyChild 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 -> GlobalDateTimeReturn Value
the current local date/time according to the database server.
-
Declaration
Swift
open func currentUTC() throws -> GlobalDateTimeReturn 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) throwsParameters
queryData query specifying the information to be deleted.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
entityParent entity.
childPropertyChild 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) throwsParameters
entityEntity to be deleted.
headersRequest-specific headers.
optionsRequest-specific options.
-
Call
deleteEntitybut 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
entityEntity to be deleted.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
fromSource entity for the link to be deleted.
propertySource navigation property for the link to be deleted.
toTarget entity for the link to be deleted.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
sourceSource entity for the link to be created.
sourcePropertySource navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.
targetTarget 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) throwsParameters
entityEntity containing the stream property whose content is to be deleted.
headersRequest-specific headers.
optionsRequest-specific options.
linkStream 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 -> ByteStreamParameters
entityEntity whose content is to be downloaded.
headersRequest-specific headers.
optionsRequest-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 -> ByteStreamParameters
entityEntity containing the stream property whose content is to be downloaded.
linkStream link for the stream to be downloaded.
headersRequest-specific headers.
optionsRequest-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
DataServiceExceptionorDataNetworkExceptionif 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
methodData method.
parametersMethod parameters.
headersRequest-specific headers.
optionsRequest-specific options.
Return Value
The method result, or
nilif 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 -> QueryResultParameters
queryData query specifying the information to be returned.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
entityEntity whose item is to be expanded.
itemItem to be expanded.
-
If
querycontains anyDataQuery.expandItems, apply them toresult.Parameters
queryQuery which may optionally contain expand items.
resultQuery 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
metadataproperty.See also
loadMetadata.Declaration
Swift
open func fetchMetadata(headers: HTTPHeaders, options: RequestOptions) throws -> CSDLDocumentParameters
headersOptional request-specific headers.
optionsOptional 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 -> BoolReturn Value
trueif 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) throwsParameters
entityPreviously loaded entity, whose properties will be modified to reflect the loaded state.
queryOptional data query, to specify loading criteria (especially for navigation properties).
headersOptional request-specific headers.
optionsOptional request-specific options.
-
Load service metadata (if not already loaded).
Declaration
Swift
open func loadMetadata(headers: HTTPHeaders, options: RequestOptions) throwsParameters
headersOptional request-specific headers.
optionsOptional 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) throwsParameters
propertyProperty to load.
intoExisting entity.
queryOptional 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) throwsParameters
headersOptional request-specific headers.
optionsOptional request-specific options.
-
Execute
workwithin a transaction.Declaration
Swift
open func prepareData(work: @escaping () throws -> Void) throwsParameters
workWork 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) throwsParameters
batchThe request batch.
headersRequest-specific headers.
optionsRequest-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 -> BoolReturn Value
trueif the database schema artifacts (e.g. tables) exist for this provider. -
Declaration
Swift
open func selectEntity(_ entity: EntityValue) throws -> EntityValueParameters
entityEntity value.
Return Value
Newly loaded copy of
entitywith 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
loaderInitial 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) -> DataMethodParameters
nameStored 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
traceRequestsis 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) throwsParameters
workWork 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) throwsParameters
entitySource entity, which may contain inline bindings for the binding property.
bindingPropertyBinding 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) throwsParameters
entityEntity to be updated.
headersRequest-specific headers.
optionsRequest-specific options.
-
Call
updateEntitybut 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
entityEntity to be updated.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
fromSource entity for the link to be updated.
propertySource navigation property for the link to be updated. This must be a one-to-one navigation property.
toTarget entity for the link to be updated.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
sourceSource entity for the link to be created.
sourcePropertySource navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.
targetTarget 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) throwsParameters
entityEntity whose content is to be uploaded.
contentUpload stream content. Will be closed before this function returns.
headersRequest-specific headers.
optionsRequest-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) throwsParameters
entityEntity containing the stream property whose content is to be uploaded.
linkStream link for the stream to be uploaded.
contentUpload stream content. Will be closed before this function returns.
headersRequest-specific headers.
optionsRequest-specific options.