-
Notifications
You must be signed in to change notification settings - Fork 46
Core Data integration #180
base: mikaela/bugfix-data
Are you sure you want to change the base?
Core Data integration #180
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll chat in Discord 👍
| init(inMemory: Bool = false) { | ||
| container = NSPersistentContainer(name: "BrainMarks") | ||
|
|
||
| if inMemory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this do?
Also considering this is a singleton, the init is supposed to be private, because you aren't supposed to have multiple instances of it at a time. Would this affect what the init does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make the init private, but this tells the app which provider to look at for tests and such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any unit tests for this? I didn't see any @heyjaywilson
Progress / Closed on issue #
What it Does
TLDR: Introduces Core Data as the main data store 💽
Adds Core Data for Tweet and Category CRUD
Core Data has been added and the supporting files can be found in the
CoreDatafolder.There are two entities.
CategoryEntityholds the categories and has a one to many relationship to theTweetEntity.TweetEntityholds the tweets and has a many to one relationship to theCategoryEntity.CoreData/StorageProvider.swiftis used to initialize theNSPersistentContainer. It haspreviewvariable which is used for the SwiftUI canvas/preview and asharedvariable which is used all other times.Migration from Amplify to Core Data
How a migration is performed:
CoreDataEntityTweetEntityand add it to theCategoryEntitytweetsHow is a Migration determined:
The following conditions must both be true for a migration to run.
storageProvider.getAllCategories().isEmptyis truemigrationToCoreDataRanis trueHow I Tested
devbranch, create a category and save some tweetsjay/bugfix-dataand see the categories look the same (migration ran)