关键词:swift、GRDB
Part One参考原文链接:swift - 使用 GRDB,使用原始 sql 但以方便的形式使用结果? - IT工具网 (coder.work)
GRDB提供了一个查询构建器
let persons = try Person.filter(emailColum != nil).fetchAll(db)
它也理解SQL
let persons = try Person.fetchAll(db,"SELECT * FROM persons WHERE email IS NOT NULL")
try dbQueue.inDatabase { db in let sql = "..." let jobs = try Job.fetchAll(db,sql) }
或者您最终可以将自定义SQL查询封装在“自定义请求中”:
extension ExtendedJob { static func filter(userId: Int64) -> AnyTypedRequest{ let request = SQLRequest( "SELECT job.id, job.name, job.city, " +