Preparation protocol

Now we have a Shopping List Model that can create, read, update, and delete the Shopping List from the database. But there are a few things missing. Our Model does not know which table or collection to save or read from, and we have not specified the rules on how to create the table or collection for the first time. We need to do so by implementing the preparations protocol, which consists of two methods. One is called prepare, which runs once and is a good place for us to create our table or collection and specify the columns and any restriction on those columns. The other method is called revert, which is used to revert the changes done in prepare, which will be to delete the database table. To add preparation, we need ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.