Skip to content

Commit 478805a

Browse files
committed
Northwind
...
1 parent 1be7a4e commit 478805a

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ Even just DocC documentation or more tests would be welcome contributions.
160160
- [ManagedModels](https://github.com/Data-swift/ManagedModels/)
161161
- [ManagedToDos.app](https://github.com/Data-swift/ManagedToDosApp)
162162
- Blog article: [`@Model` for CoreData](https://www.alwaysrightinstitute.com/managedmodels/)
163+
- [Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels)
164+
(more complex example, schema with many entities and a prefilled DB for
165+
testing)
163166
- Apple:
164167
- [CoreData](https://developer.apple.com/documentation/coredata)
165168
- [SwiftData](https://developer.apple.com/documentation/swiftdata)

Sources/ManagedModels/Documentation.docc/Documentation.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,53 @@ struct ToDoListView: View {
5454
- Example ToDo list app: [https://github.com/Data-swift/ManagedToDosApp.git](https://github.com/Data-swift/ManagedToDosApp/)
5555

5656

57+
## Northwind
58+
59+
A little bigger example,
60+
a port of a demo database for SwiftData to ManagedModels:
61+
[Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels)
62+
(SwiftData original:
63+
[NorthwindSwiftData](https://github.com/Northwind-swift/NorthwindSwiftData)).
64+
65+
This is the old [Northwind database](https://github.com/jpwhite3/northwind-SQLite3)
66+
packaged up as a Swift package that works with ManagedModels.
67+
It contains a set of model classes and a prefilled database which makes it ideal
68+
for testing, to get started quickly.
69+
70+
Sample usage
71+
(import `https://github.com/Northwind-swift/NorthwindSwiftData.git`):
72+
```swift
73+
import SwiftUI
74+
import NorthwindSwiftData // @Northwind-swift/NorthwindManagedModels
75+
76+
@main
77+
struct NorthwindApp: App {
78+
79+
var body: some Scene {
80+
WindowGroup {
81+
ContentView()
82+
}
83+
.modelContainer(try! NorthwindStore.modelContainer())
84+
}
85+
}
86+
87+
struct ContentView: View {
88+
89+
@FetchRequest(sort: \.name)
90+
private var products: FetchedResults<Product>
91+
92+
var body: some View {
93+
List {
94+
ForEach(products) { product in
95+
Text(verbatim: product.name)
96+
}
97+
}
98+
}
99+
}
100+
```
101+
102+
- [Northwind for ManagedModels Documentation](https://swiftpackageindex.com/Northwind-swift/NorthwindManagedModels/documentation/northwindswiftdata)
103+
57104

58105
## Topics
59106

Sources/ManagedModels/Documentation.docc/Links.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Swift Package URL: `https://github.com/Data-swift/ManagedModels.git`
1010
- [ManagedModels](https://github.com/Data-swift/ManagedModels/)
1111
- filing [GitHub Issues](https://github.com/Data-swift/ManagedModels/issues)
1212
- [Managed ToDos](https://github.com/Data-swift/ManagedToDosApp/) example app
13+
- [Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels)
14+
(more complex example, schema with many entities and a prefilled DB for
15+
testing)
1316

1417

1518
## Apple

0 commit comments

Comments
 (0)