AWSDynamoDBObjectMapper Class Reference

Inherits from AWSService : NSObject
Declared in AWSDynamoDBObjectMapper.h
AWSDynamoDBObjectMapper.m

Overview

Object mapper for domain-object interaction with DynamoDB.

  objectMapperConfiguration

The service configuration used to instantiate this service client.

@property (nonatomic, strong, readonly) AWSDynamoDBObjectMapperConfiguration *objectMapperConfiguration

Discussion

Warning: Once the client is instantiated, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSDynamoDBObjectMapper.h

+ defaultDynamoDBObjectMapper

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.

+ (instancetype)defaultDynamoDBObjectMapper

Return Value

The default service client.

Discussion

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];

Declared In

AWSDynamoDBObjectMapper.h

+ registerDynamoDBObjectMapperWithConfiguration:objectMapperConfiguration:forKey:

Creates a service client with the given service configuration and registers it for the key.

+ (void)registerDynamoDBObjectMapperWithConfiguration:(AWSServiceConfiguration *)configuration objectMapperConfiguration:(AWSDynamoDBObjectMapperConfiguration *)objectMapperConfiguration forKey:(NSString *)key

Parameters

configuration

A service configuration object.

objectMapperConfiguration

The DynamoDB Object Mapper configuration object.

key

A string to identify the service client.

Discussion

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.

Declared In

AWSDynamoDBObjectMapper.h

+ DynamoDBObjectMapperForKey:

Retrieves the service client associated with the key. You need to call + registerDynamoDBObjectMapperWithConfiguration:forKey: before invoking this method.

+ (instancetype)DynamoDBObjectMapperForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Return Value

An instance of the service client.

Discussion

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"];

Declared In

AWSDynamoDBObjectMapper.h

+ removeDynamoDBObjectMapperForKey:

Removes the service client associated with the key and release it.

+ (void)removeDynamoDBObjectMapperForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Discussion

Warning: Before calling this method, make sure no method is running on this client.

Declared In

AWSDynamoDBObjectMapper.h

– save:

Saves the model object to an Amazon DynamoDB table using the default configuration.

- (AWSTask *)save:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model

Parameters

model

A model to save.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– save:completionHandler:

Saves the model object to an Amazon DynamoDB table using the default configuration.

- (void)save:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model completionHandler:(void ( ^ _Nullable ) ( NSError *_Nullable error ))completionHandler

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, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– save:configuration:

Saves the model object to an Amazon DynamoDB table using the specified configuration.

- (AWSTask *)save:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration

Parameters

model

A model to save.

configuration

A configuration.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– save:configuration:completionHandler:

Saves the model object to an Amazon DynamoDB table using the specified configuration.

- (void)save:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void ( ^ _Nullable ) ( NSError *_Nullable error ))completionHandler

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, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– remove:

Removes the given model object from the Amazon DynamoDB table using the default configuration.

- (AWSTask *)remove:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model

Parameters

model

A model to delete.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– remove:completionHandler:

Removes the given model object from the Amazon DynamoDB table using the default configuration.

- (void)remove:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model completionHandler:(void ( ^ _Nullable ) ( NSError *_Nullable error ))completionHandler

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, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– remove:configuration:

Removes the given model object from the Amazon DynamoDB table using the specified configuration.

- (AWSTask *)remove:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration

Parameters

model

A model to delete.

configuration

A configuration.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– remove:configuration:completionHandler:

Removes the given model object from the Amazon DynamoDB table using the specified configuration.

- (void)remove:(AWSDynamoDBObjectModel<AWSDynamoDBModeling> *)model configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void ( ^ _Nullable ) ( NSError *_Nullable error ))completionHandler

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, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– load:hashKey:rangeKey:

Returns an object with the given hash key and the range key (if it exists), or nil if no such object exists.

- (AWSTask *)load:(Class)resultClass hashKey:(id)hashKey rangeKey:(nullable id)rangeKey

Parameters

resultClass

The class of the result object.

hashKey

A hash key value.

rangeKey

A range key value.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– load:hashKey:rangeKey:completionHandler:

Returns an object with the given hash key and the range key (if it exists), or nil if no such object exists.

- (void)load:(Class)resultClass hashKey:(id)hashKey rangeKey:(nullable id)rangeKey completionHandler:(void ( ^ _Nullable ) ( AWSDynamoDBObjectModel<AWSDynamoDBModeling> *_Nullable response , NSError *_Nullable error ))completionHandler

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, or nil if no such object exists. error: An error object that indicates why the request failed, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– load:hashKey:rangeKey:configuration:

Returns an object with the given hash key and the range key (if it exists), or nil if no such object exists.

- (AWSTask *)load:(Class)resultClass hashKey:(id)hashKey rangeKey:(nullable id)rangeKey configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration

Parameters

resultClass

The class of the result object.

hashKey

A hash key value.

rangeKey

A range key value.

configuration

A configuration.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– load:hashKey:rangeKey:configuration:completionHandler:

Returns an object with the given hash key and the range key (if it exists), or nil if no such object exists.

- (void)load:(Class)resultClass hashKey:(id)hashKey rangeKey:(nullable id)rangeKey configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void ( ^ _Nullable ) ( AWSDynamoDBObjectModel<AWSDynamoDBModeling> *_Nullable response , NSError *_Nullable error ))completionHandler

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, or nil if no such object exists. error: An error object that indicates why the request failed, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– query:expression:

Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects, using the default configuration.

- (AWSTask<AWSDynamoDBPaginatedOutput*> *)query:(Class)resultClass expression:(AWSDynamoDBQueryExpression *)expression

Parameters

resultClass

The class of the result object.

expression

An expression object.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– query:expression:completionHandler:

Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects.

- (void)query:(Class)resultClass expression:(AWSDynamoDBQueryExpression *)expression completionHandler:(void ( ^ _Nullable ) ( AWSDynamoDBPaginatedOutput *_Nullable response , NSError *_Nullable error ))completionHandler

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, or nil if no such object exists. error: An error object that indicates why the request failed, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– query:expression:configuration:

Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects.

- (AWSTask<AWSDynamoDBPaginatedOutput*> *)query:(Class)resultClass expression:(AWSDynamoDBQueryExpression *)expression configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration

Parameters

resultClass

The class of the result object.

expression

An expression object.

configuration

A configuration.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– query:expression:configuration:completionHandler:

Queries an Amazon DynamoDB table and returns the matching results as an unmodifiable list of instantiated objects.

- (void)query:(Class)resultClass expression:(AWSDynamoDBQueryExpression *)expression configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void ( ^ _Nullable ) ( AWSDynamoDBPaginatedOutput *_Nullable response , NSError *_Nullable error ))completionHandler

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, or nil if no such object exists. error: An error object that indicates why the request failed, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– scan:expression:

Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects, using the default configuration.

- (AWSTask<AWSDynamoDBPaginatedOutput*> *)scan:(Class)resultClass expression:(AWSDynamoDBScanExpression *)expression

Parameters

resultClass

The class of the result object.

expression

An expression object.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– scan:expression:completionHandler:

Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects.

- (void)scan:(Class)resultClass expression:(AWSDynamoDBScanExpression *)expression completionHandler:(void ( ^ _Nullable ) ( AWSDynamoDBPaginatedOutput *_Nullable response , NSError *_Nullable error ))completionHandler

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, or nil if no such object exists. error: An error object that indicates why the request failed, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h

– scan:expression:configuration:

Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects.

- (AWSTask<AWSDynamoDBPaginatedOutput*> *)scan:(Class)resultClass expression:(AWSDynamoDBScanExpression *)expression configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration

Parameters

resultClass

The class of the result object.

expression

An expression object.

configuration

A configuration.

Return Value

AWSTask.

Declared In

AWSDynamoDBObjectMapper.h

– scan:expression:configuration:completionHandler:

Scans through an Amazon DynamoDB table and returns the matching results as an AWSDynamoDBPaginatedOutput of instantiated objects.

- (void)scan:(Class)resultClass expression:(AWSDynamoDBScanExpression *)expression configuration:(nullable AWSDynamoDBObjectMapperConfiguration *)configuration completionHandler:(void ( ^ _Nullable ) ( AWSDynamoDBPaginatedOutput *_Nullable response , NSError *_Nullable error ))completionHandler

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, or nil if no such object exists. error: An error object that indicates why the request failed, or nil if the request was successful.

Declared In

AWSDynamoDBObjectMapper.h