AWSDynamoDBObjectMapper
Objective-C
@interface AWSDynamoDBObjectMapper
Swift
class AWSDynamoDBObjectMapper
Object mapper for domain-object interaction with DynamoDB.
-
The service configuration used to instantiate this service client.
Warning
Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.Declaration
Objective-C
@property (nonatomic, strong, readonly) AWSDynamoDBObjectMapperConfiguration *_Nonnull objectMapperConfiguration;
Swift
var objectMapperConfiguration: AWSDynamoDBObjectMapperConfiguration { get }
-
Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with
defaultServiceConfiguration
from[AWSServiceManager defaultServiceManager]
. The reference to this object is maintained by the SDK, and you do not need to retain it manually.For example, set the default service configuration in
- application:didFinishLaunchingWithOptions:
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId") let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider) AWSServiceManager.default().defaultServiceConfiguration = configuration return true }
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"]; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider]; [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; return YES; }
Then call the following to get the default service client:
Swift
let DynamoDBObjectMapper = AWSDynamoDBObjectMapper.default()
Objective-C
AWSDynamoDBObjectMapper *DynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
Declaration
Objective-C
+ (nonnull instancetype)defaultDynamoDBObjectMapper;
Swift
class func `default`() -> Self
Return Value
The default service client.
-
Creates a service client with the given service configuration and registers it for the key.
For example, set the default service configuration in
- application:didFinishLaunchingWithOptions:
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId") let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider) let objectMapperConfiguration = AWSDynamoDBObjectMapperConfiguration() AWSDynamoDBObjectMapper.register(with: configuration!, objectMapperConfiguration: objectMapperConfigration, forKey: "USWest2DynamoDBObjectMapper") return true }
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"]; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider]; AWSDynamoDBObjectMapperConfiguration objectMapperConfiguration = [[AWSDynamoDBObjectMapperConfiguration alloc] init]; [AWSDynamoDBObjectMapper registerDynamoDBObjectMapperWithConfiguration:configuration objectMapperConfiguration:objectMapperConfiguration forKey:@"USWest2DynamoDBObjectMapper"]; return YES; }
Then call the following to get the service client:
Swift
let DynamoDBObjectMapper = AWSDynamoDBObjectMapper(forKey: "USWest2DynamoDBObjectMapper")
Objective-C
AWSDynamoDBObjectMapper *DynamoDBObjectMapper = [AWSDynamoDBObjectMapper DynamoDBObjectMapperForKey:@"USWest2DynamoDBObjectMapper"];
Warning
After calling this method, do not modify the configuration object. It may cause unspecified behaviors.
Declaration
Objective-C
+ (void)registerDynamoDBObjectMapperWithConfiguration:(id)configuration objectMapperConfiguration: (nonnull AWSDynamoDBObjectMapperConfiguration *) objectMapperConfiguration forKey:(nonnull NSString *)key;
Swift
class func register(withConfiguration configuration: Any!, objectMapperConfiguration: AWSDynamoDBObjectMapperConfiguration, forKey key: String)
Parameters
configuration
A service configuration object.
objectMapperConfiguration
The DynamoDB Object Mapper configuration object.
key
A string to identify the service client.
-
Retrieves the service client associated with the key. You need to call
+ registerDynamoDBObjectMapperWithConfiguration:forKey:
before invoking this method.For example, set the default service configuration in
- application:didFinishLaunchingWithOptions:
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId") let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider) let objectMapperConfiguration = AWSDynamoDBObjectMapperConfiguration() AWSDynamoDBObjectMapper.register(with: configuration!, objectMapperConfiguration: objectMapperConfigration, forKey: "USWest2DynamoDBObjectMapper") return true }
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"]; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider]; AWSDynamoDBObjectMapperConfiguration objectMapperConfiguration = [[AWSDynamoDBObjectMapperConfiguration alloc] init]; [AWSDynamoDBObjectMapper registerDynamoDBObjectMapperWithConfiguration:configuration objectMapperConfiguration:objectMapperConfiguration forKey:@"USWest2DynamoDBObjectMapper"]; return YES; }
Then call the following to get the service client:
Swift
let DynamoDBObjectMapper = AWSDynamoDBObjectMapper(forKey: "USWest2DynamoDBObjectMapper")
Objective-C
AWSDynamoDBObjectMapper *DynamoDBObjectMapper = [AWSDynamoDBObjectMapper DynamoDBObjectMapperForKey:@"USWest2DynamoDBObjectMapper"];
Declaration
Objective-C
+ (nonnull instancetype)DynamoDBObjectMapperForKey:(nonnull NSString *)key;
Swift
convenience init(forKey key: String)
Parameters
key
A string to identify the service client.
Return Value
An instance of the service client.
-
Removes the service client associated with the key and release it.
Warning
Before calling this method, make sure no method is running on this client.
Declaration
Objective-C
+ (void)removeDynamoDBObjectMapperForKey:(nonnull NSString *)key;
Swift
class func remove(forKey key: String)
Parameters
key
A string to identify the service client.
-
Saves the model object to an Amazon DynamoDB table using the default configuration.
Declaration
Objective-C
- (id)save:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model;
Swift
func save(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling) -> Any!
Parameters
model
A model to save.
Return Value
AWSTask.
-
Saves the model object to an Amazon DynamoDB table using the default configuration.
Declaration
Objective-C
- (void)save:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func save(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling) async throws
Parameters
model
A model to save.
completionHandler
The completion handler to call when the load request is complete.
error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Saves the model object to an Amazon DynamoDB table using the specified configuration.
Declaration
Objective-C
- (id)save:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration;
Swift
func save(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling, configuration: AWSDynamoDBObjectMapperConfiguration?) -> Any!
Parameters
model
A model to save.
configuration
A configuration.
Return Value
AWSTask.
-
Saves the model object to an Amazon DynamoDB table using the specified configuration.
Declaration
Objective-C
- (void)save:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func save(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling, configuration: AWSDynamoDBObjectMapperConfiguration?) async throws
Parameters
model
A model to save.
configuration
A configuration.
completionHandler
The completion handler to call when the load request is complete.
error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Removes the given model object from the Amazon DynamoDB table using the default configuration.
Declaration
Objective-C
- (id)remove:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model;
Swift
func remove(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling) -> Any!
Parameters
model
A model to delete.
Return Value
AWSTask.
-
Removes the given model object from the Amazon DynamoDB table using the default configuration.
Declaration
Objective-C
- (void)remove:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func remove(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling) async throws
Parameters
model
A model to delete.
completionHandler
The completion handler to call when the load request is complete.
error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Removes the given model object from the Amazon DynamoDB table using the specified configuration.
Declaration
Objective-C
- (id)remove:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration;
Swift
func remove(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling, configuration: AWSDynamoDBObjectMapperConfiguration?) -> Any!
Parameters
model
A model to delete.
configuration
A configuration.
Return Value
AWSTask.
-
Removes the given model object from the Amazon DynamoDB table using the specified configuration.
Declaration
Objective-C
- (void)remove:(nonnull AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void (^_Nullable)(NSError *_Nullable))completionHandler;
Swift
func remove(_ model: AWSDynamoDBObjectModel & AWSDynamoDBModeling, configuration: AWSDynamoDBObjectMapperConfiguration?) async throws
Parameters
model
A model to delete.
configuration
A configuration.
completionHandler
The completion handler to call when the load request is complete.
error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Returns an object with the given hash key and the range key (if it exists), or
nil
if no such object exists.Declaration
Objective-C
- (id)load:(nonnull Class)resultClass hashKey:(nonnull id)hashKey rangeKey:(nullable id)rangeKey;
Swift
func load(_ resultClass: AnyClass, hashKey: Any, rangeKey: Any?) -> Any!
Parameters
resultClass
The class of the result object.
hashKey
A hash key value.
rangeKey
A range key value.
Return Value
AWSTask.
-
Returns an object with the given hash key and the range key (if it exists), or
nil
if no such object exists.Declaration
Objective-C
- (void)load:(nonnull Class)resultClass hashKey:(nonnull id)hashKey rangeKey:(nullable id)rangeKey completionHandler: (void (^_Nullable)( AWSDynamoDBObjectModel<AWSDynamoDBModeling> *_Nullable, NSError *_Nullable))completionHandler;
Swift
func load(_ resultClass: AnyClass, hashKey: Any, rangeKey: Any?) async throws -> AWSDynamoDBObjectModel & AWSDynamoDBModeling
Parameters
resultClass
The class of the result object.
hashKey
A hash key value.
rangeKey
A range key value.
completionHandler
The completion handler to call when the load request is complete.
response
: The specified model object, ornil
if no such object exists.error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Returns an object with the given hash key and the range key (if it exists), or
nil
if no such object exists.Declaration
Objective-C
- (id)load:(nonnull Class)resultClass hashKey:(nonnull id)hashKey rangeKey:(nullable id)rangeKey configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration;
Swift
func load(_ resultClass: AnyClass, hashKey: Any, rangeKey: Any?, configuration: AWSDynamoDBObjectMapperConfiguration?) -> Any!
Parameters
resultClass
The class of the result object.
hashKey
A hash key value.
rangeKey
A range key value.
configuration
A configuration.
Return Value
AWSTask.
-
Returns an object with the given hash key and the range key (if it exists), or
nil
if no such object exists.Declaration
Objective-C
- (void)load:(nonnull Class)resultClass hashKey:(nonnull id)hashKey rangeKey:(nullable id)rangeKey configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler: (void (^_Nullable)( AWSDynamoDBObjectModel<AWSDynamoDBModeling> *_Nullable, NSError *_Nullable))completionHandler;
Swift
func load(_ resultClass: AnyClass, hashKey: Any, rangeKey: Any?, configuration: AWSDynamoDBObjectMapperConfiguration?) async throws -> AWSDynamoDBObjectModel & AWSDynamoDBModeling
Parameters
resultClass
The class of the result object.
hashKey
A hash key value.
rangeKey
A range key value.
configuration
A configuration.
completionHandler
The completion handler to call when the load request is complete.
response
: The specified model object, ornil
if no such object exists.error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects, using the default configuration.
Declaration
Objective-C
- (id)query:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBQueryExpression *)expression;
Swift
func query(_ resultClass: AnyClass, expression: AWSDynamoDBQueryExpression) -> Any!
Parameters
resultClass
The class of the result object.
expression
An expression object.
Return Value
AWSTask.
-
Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects.
Declaration
Objective-C
- (void)query:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBQueryExpression *)expression completionHandler:(void (^_Nullable)(AWSDynamoDBPaginatedOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func query(_ resultClass: AnyClass, expression: AWSDynamoDBQueryExpression) async throws -> AWSDynamoDBPaginatedOutput
Parameters
resultClass
The class of the result object.
expression
An expression object.
completionHandler
The completion handler to call when the load request is complete.
response
:AWSDynamoDBPaginatedOutput
that contains a list of model objects, ornil
if no such object exists.error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects.
Declaration
Objective-C
- (id)query:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBQueryExpression *)expression configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration;
Swift
func query(_ resultClass: AnyClass, expression: AWSDynamoDBQueryExpression, configuration: AWSDynamoDBObjectMapperConfiguration?) -> Any!
Parameters
resultClass
The class of the result object.
expression
An expression object.
configuration
A configuration.
Return Value
AWSTask.
-
Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects.
Declaration
Objective-C
- (void)query:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBQueryExpression *)expression configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void (^_Nullable)(AWSDynamoDBPaginatedOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func query(_ resultClass: AnyClass, expression: AWSDynamoDBQueryExpression, configuration: AWSDynamoDBObjectMapperConfiguration?) async throws -> AWSDynamoDBPaginatedOutput
Parameters
resultClass
The class of the result object.
expression
An expression object.
configuration
A configuration.
completionHandler
The completion handler to call when the load request is complete.
response
:AWSDynamoDBPaginatedOutput
that contains a list of model objects, ornil
if no such object exists.error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects, using the default configuration.
Declaration
Objective-C
- (id)scan:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBScanExpression *)expression;
Swift
func scan(_ resultClass: AnyClass, expression: AWSDynamoDBScanExpression) -> Any!
Parameters
resultClass
The class of the result object.
expression
An expression object.
Return Value
AWSTask.
-
Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects.
Declaration
Objective-C
- (void)scan:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBScanExpression *)expression completionHandler:(void (^_Nullable)(AWSDynamoDBPaginatedOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func scan(_ resultClass: AnyClass, expression: AWSDynamoDBScanExpression) async throws -> AWSDynamoDBPaginatedOutput
Parameters
resultClass
The class of the result object.
expression
An expression object.
completionHandler
The completion handler to call when the load request is complete.
response
:AWSDynamoDBPaginatedOutput
that contains a list of model objects, ornil
if no such object exists.error
: An error object that indicates why the request failed, ornil
if the request was successful. -
Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects.
Declaration
Objective-C
- (id)scan:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBScanExpression *)expression configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration;
Swift
func scan(_ resultClass: AnyClass, expression: AWSDynamoDBScanExpression, configuration: AWSDynamoDBObjectMapperConfiguration?) -> Any!
Parameters
resultClass
The class of the result object.
expression
An expression object.
configuration
A configuration.
Return Value
AWSTask.
-
Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects.
Declaration
Objective-C
- (void)scan:(nonnull Class)resultClass expression:(nonnull AWSDynamoDBScanExpression *)expression configuration: (nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void (^_Nullable)(AWSDynamoDBPaginatedOutput *_Nullable, NSError *_Nullable))completionHandler;
Swift
func scan(_ resultClass: AnyClass, expression: AWSDynamoDBScanExpression, configuration: AWSDynamoDBObjectMapperConfiguration?) async throws -> AWSDynamoDBPaginatedOutput
Parameters
resultClass
The class of the result object.
expression
An expression object.
configuration
A configuration.
completionHandler
The completion handler to call when the load request is complete.
response
:AWSDynamoDBPaginatedOutput
that contains a list of model objects, ornil
if no such object exists.error
: An error object that indicates why the request failed, ornil
if the request was successful.