diff --git a/README.md b/README.md index e8d9bad..ea360bb 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,9 @@ Even just DocC documentation or more tests would be welcome contributions. - [ManagedModels](https://github.com/Data-swift/ManagedModels/) - [ManagedToDos.app](https://github.com/Data-swift/ManagedToDosApp) - Blog article: [`@Model` for CoreData](https://www.alwaysrightinstitute.com/managedmodels/) + - [Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels) + (more complex example, schema with many entities and a prefilled DB for + testing) - Apple: - [CoreData](https://developer.apple.com/documentation/coredata) - [SwiftData](https://developer.apple.com/documentation/swiftdata) diff --git a/Sources/ManagedModels/Documentation.docc/Documentation.md b/Sources/ManagedModels/Documentation.docc/Documentation.md index a1b35ff..0aeca7e 100644 --- a/Sources/ManagedModels/Documentation.docc/Documentation.md +++ b/Sources/ManagedModels/Documentation.docc/Documentation.md @@ -54,6 +54,53 @@ struct ToDoListView: View { - Example ToDo list app: [https://github.com/Data-swift/ManagedToDosApp.git](https://github.com/Data-swift/ManagedToDosApp/) +## Northwind + +A little bigger example, +a port of a demo database for SwiftData to ManagedModels: +[Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels) +(SwiftData original: + [NorthwindSwiftData](https://github.com/Northwind-swift/NorthwindSwiftData)). + +This is the old [Northwind database](https://github.com/jpwhite3/northwind-SQLite3) +packaged up as a Swift package that works with ManagedModels. +It contains a set of model classes and a prefilled database which makes it ideal +for testing, to get started quickly. + +Sample usage +(import `https://github.com/Northwind-swift/NorthwindSwiftData.git`): +```swift +import SwiftUI +import NorthwindSwiftData // @Northwind-swift/NorthwindManagedModels + +@main +struct NorthwindApp: App { + + var body: some Scene { + WindowGroup { + ContentView() + } + .modelContainer(try! NorthwindStore.modelContainer()) + } +} + +struct ContentView: View { + + @FetchRequest(sort: \.name) + private var products: FetchedResults + + var body: some View { + List { + ForEach(products) { product in + Text(verbatim: product.name) + } + } + } +} +``` + +- [Northwind for ManagedModels Documentation](https://swiftpackageindex.com/Northwind-swift/NorthwindManagedModels/documentation/northwindswiftdata) + ## Topics diff --git a/Sources/ManagedModels/Documentation.docc/Links.md b/Sources/ManagedModels/Documentation.docc/Links.md index a0f71a6..69f7cd3 100644 --- a/Sources/ManagedModels/Documentation.docc/Links.md +++ b/Sources/ManagedModels/Documentation.docc/Links.md @@ -10,6 +10,9 @@ Swift Package URL: `https://github.com/Data-swift/ManagedModels.git` - [ManagedModels](https://github.com/Data-swift/ManagedModels/) - filing [GitHub Issues](https://github.com/Data-swift/ManagedModels/issues) - [Managed ToDos](https://github.com/Data-swift/ManagedToDosApp/) example app +- [Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels) + (more complex example, schema with many entities and a prefilled DB for + testing) ## Apple