This repository was archived by the owner on Aug 18, 2023. It is now read-only.
Core Data integration#180
Open
heyjaywilson wants to merge 18 commits intomikaelacaron:mikaela/bugfix-datafrom
Open
Core Data integration#180heyjaywilson wants to merge 18 commits intomikaelacaron:mikaela/bugfix-datafrom
heyjaywilson wants to merge 18 commits intomikaelacaron:mikaela/bugfix-datafrom
Conversation
heyjaywilson
commented
Dec 31, 2022
heyjaywilson
commented
Dec 31, 2022
heyjaywilson
commented
Dec 31, 2022
mikaelacaron
suggested changes
Jan 16, 2023
| init(inMemory: Bool = false) { | ||
| container = NSPersistentContainer(name: "BrainMarks") | ||
|
|
||
| if inMemory { |
Owner
There was a problem hiding this comment.
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?
Author
There was a problem hiding this comment.
I'll make the init private, but this tells the app which provider to look at for tests and such.
Owner
There was a problem hiding this comment.
Are there any unit tests for this? I didn't see any @heyjaywilson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)