vmanot/SwiftDB
vmanot/SwiftDB has 338 GitHub stars and 8 forks. Star changes are not measured yet. Last checked 2026-11-14 02:10 UTC. Last push 2025-08-06.
Measured star growth
- in 24h
- Collecting history
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
A modern database abstraction layer + runtime, batteries included [WIP].
DataREADME.md
OriginalSwiftDB [WIP]
[!IMPORTANT] This package is under development and is being currently rewritten to fully leverage Swift 5.9.
A modern, type-safe database abstraction layer. SwiftDB aims to be an opinionated DBAL for relational and document-oriented databases.
Get Started
Define an Entity:
struct Foo: Entity, Identifiable {
@Attribute var bar: String = "Untitled"
var id: some Hashable {
bar
}
}
Define a Schema:
struct MySchema: Schema {
var entities: Entities {
Foo.self
}
}
Create a ContentView for your application:
struct ContentView: View {
@StateObject var container = PersistentContainer(MySchema())
var body: some View {
Text("Hello World")
}
}
Create a list view:
struct ListView: View {
@EnvironmentObject var container: PersistentContainer
@QueryModels<Foo>() var models
var body: some View {
NavigationView {
List(models) { foo in
NavigationLink(destination: EditView(foo: foo)) {
Text(foo.bar)
}
.contextMenu {
Button {
container.delete(foo)
} label: {
Text("Delete")
}
}
}
.navigationBarItems(
trailing: Button {
container.create(Foo.self)
} label: {
Image(systemName: .plusCircleFill)
.imageScale(.large)
}
)
.navigationBarTitle("A List of Foo")
}
}
struct EditView: View {
@EnvironmentObject var container: PersistentContainer
let foo: Foo
var body: some View {
VStack {
Form {
TextField("Enter a value", text: foo.$bar) {
container.save()
}
}
}
.navigationBarTitle("Edit Foo")
}
}
}
Add it to our ContentView:
struct ContentView: View {
@StateObject var container = PersistentContainer(MySchema())
var body: some View {
ListView()
.databaseContainer(container)
}
}
That's it.
Explore related projects
Asabeneh/30-Days-Of-Python
The 30 Days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than 100 days. Follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,710 starsgrafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
77,892 starsredis/redis
For developers, who are building real-time data-driven applications, Redis is the preferred, fastest, and most feature-rich cache, data structure server, and document and vector query engine.
77,490 starsapache/superset
Apache Superset is a Data Visualization and Data Exploration Platform
75,521 stars