Moving your local app database to the server doesn't have to be painful. DynamoDB allows for easy creation of tables mirroring the local data stored in your app. If you currently use a local database such as SQLite, you can use the existing the definition of the classes to architect your online database to match.
- [Instructor] Now we're going to move into the stage where we migrate our database from the local storage and core data in our app to the server. So we're going to go back to the AWS console and back to the mobile hub. We'll pick our project and our app. And we're going to integrate a NoSQL database. So under Add More Backend Features, we just select NoSQL Database. And all we have to do is click this Enable NoSQL. Now we've enabled it, but we don't have any tables.
So we're going to add a table that mirrors our data from the app. So let's go back and look at our model in the app. So back into Xcode I'm going to open up our model and I see that I have a description that's a string, an isDone that's a boolean, and a todoDate that's a date. So now I want to mirror those in DynamoDB. So I'll click Add Table. I'm going to set it up as a custom table. We'll make it protected so that only the app users can read the to do items.
And I'll name the table ToDoDateOnline. This will help us distinguish the classes when they're in the code. We already have one attribute of user id. That'll allows us to know who owns the given to do item. We'll also add an item id, the description like we had in our model, the isDone, also like our model. And I'll make that one a boolean. And a todoDate from our model. And I'll make this one a number.
We can sort by that key if we'd like, but it's not required. We're going to created this table. And it'll create it for us in DynamoDB. So now that we've made these changes, we need to integrate it with the app. So again we have the banner telling us we need to integrate and the integrate button is flashing. We want to download a new cloud config file but we still have the old one. So let's delete that one first. So in Finder, I'm going to select the AWS configuration file that's currently there and delete it.
Back in Chrome I'll download the new configuration file and I'm also going to download the swift model code. I'll click Next, save the help links, and I'm done. Now back in Xcode I want to add the new configuration file, so I'll delete the old one. I also want to add the model files that we downloaded. So I'll select add files again, downloads, and you see I need to unzip that file.
So let's go to Finder to do that. So in Finder I'll double click the file to unzip it. And I can see that I've got the model code files from the NoSQL database. So now in Xcode I can add the files from whatever level I like. I'm just going to adds the file itself, ToDoDateOnline. Now I've got it in the code and we can see the functionality and properties that it has. I haven't added the CocoaPod yet, so we need to do that back in Terminal.
We need to to add the AWS DynamoDB pod. So once again, I'll edit the pod file adding the new pod. So pod AWSDynamoDB. I'll save and close that and run pod install again. Now our project's been reloaded and we should be able to build it successfully. And it's ready to handle data online.
- Setting up an AWS account and console
- Configuring an app for user authentication
- Migrating a database to AWS
- Retaining a local SQLite database
- Moving app data storage online
- Displaying server data in app
- Controlling app revisions
- Managing builds and deployments
- Integrating dev environments
- Migrating iOS app functionality to the cloud
- Connecting online via APIs