Convert objects to realm-native

This commit is contained in:
ronaldheft 2022-08-10 17:09:49 -04:00
parent a3e458fcc4
commit a9d7fbc083
12 changed files with 896 additions and 496 deletions

View file

@ -7,33 +7,20 @@
import Foundation
import RealmSwift
import Unrealm
struct ServerConnectionConfig: Realmable {
var id: String = UUID().uuidString
var index: Int = 1
var name: String = ""
var address: String = ""
var userId: String = ""
var username: String = ""
var token: String = ""
static func primaryKey() -> String? {
return "id"
}
static func indexedProperties() -> [String] {
return ["index"]
}
class ServerConnectionConfig: Object {
@Persisted(primaryKey: true) var id: String = UUID().uuidString
@Persisted(indexed: true) var index: Int = 1
@Persisted var name: String = ""
@Persisted var address: String = ""
@Persisted var userId: String = ""
@Persisted var username: String = ""
@Persisted var token: String = ""
}
struct ServerConnectionConfigActiveIndex: Realmable {
class ServerConnectionConfigActiveIndex: Object {
// This could overflow, but you really would have to try
var index: Int?
static func primaryKey() -> String? {
return "index"
}
@Persisted(primaryKey: true) var index: Int?
}
func convertServerConnectionConfigToJSON(config: ServerConnectionConfig) -> Dictionary<String, Any> {