struct Home: TableCodable {
var id: Int = 0
var name: String = ""
var room: Room?
enum CodingKeys: String, CodingTableKey {
typealias Root = Home
static let objectRelationalMapping = TableBinding(CodingKeys.self)
case id
case name
case room
}
}
struct Room: ColumnJSONCodable {
var id: Int = 0
var content: String = ""
var name: String = ""
}
I have created the table "Home", how can I perform a fuzzy search on the content field of Room?
I try to use this code, but it doesn't work.
let keyword = "%\(key)%"
let homes: [Home] = try! database.getObjects(fromTable: "Home", where: Home.Properties.room.like(keyword))
ColumnJSONCodable use JSONDecoder to encode your model into a json data. The json data may not use utf8 encoding for strings, while SQLite uses utf8 format for text matching.
The language of WCDB
Swift
The version of WCDB
v2.1.6
The platform of WCDB
iOS
The installation of WCDB
Package
What's the issue?
I have created the table "Home", how can I perform a fuzzy search on the content field of Room?
I try to use this code, but it doesn't work.