Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
710 changes: 710 additions & 0 deletions Demo/GRDB Demo/GRDB Demo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Demo/GRDB Demo/GRDB Demo/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "pslogo.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
14 changes: 14 additions & 0 deletions Demo/GRDB Demo/GRDB Demo/Assets.xcassets/logo.imageset/pslogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions Demo/GRDB Demo/GRDB Demo/Data/List.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import GRDB
import PowerSync

/// PowerSync client side schema
let listsTable = Table(
name: "lists",
columns: [
.text("name"),
.text("owner_id")
]
)

struct List: Codable, Equatable, Identifiable, FetchableRecord, PersistableRecord {
var id: String
var name: String
var ownerId: String

static var databaseTableName = "lists"


enum CodingKeys: String, CodingKey {
case id
case name
case ownerId = "owner_id"
}

enum Columns {
static let id = Column(CodingKeys.id)
static let name = Column(CodingKeys.name)
static let ownerId = Column(CodingKeys.ownerId)
}

static let todos = hasMany(
Todo.self, key: "todos",
using: ForeignKey([Todo.Columns.listId], to: [Columns.id])
)
}

/// Result for displaying lists in the main view
struct ListWithTodoCounts: Decodable, Hashable, Identifiable, FetchableRecord {
var id: String
var name: String
var pendingCount: Int
}
41 changes: 41 additions & 0 deletions Demo/GRDB Demo/GRDB Demo/Data/Todo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Foundation
import GRDB
import PowerSync

/// PowerSync client side schema
let todosTable = Table(
name: "todos",
columns: [
.text("name"),
.text("list_id"),
// Conversion should automatically be handled by GRDB
.integer("completed"),
.text("completed_at")
]
)

struct Todo: Codable, Equatable, Identifiable, FetchableRecord, PersistableRecord {
var id: String
var name: String
var listId: String
var isCompleted: Bool
var completedAt: Date?

static var databaseTableName = "todos"

enum CodingKeys: String, CodingKey {
case id
case name
case listId = "list_id"
case isCompleted = "completed"
case completedAt = "completed_at"
}

enum Columns {
static let id = Column(CodingKeys.id)
static let name = Column(CodingKeys.name)
static let listId = Column(CodingKeys.listId)
static let isCompleted = Column(CodingKeys.isCompleted)
static let completedAt = Column(CodingKeys.completedAt)
}
}
Loading
Loading