Closed TKNgu closed 4 years ago
Update build model from scratch run OK.
import Vapor
import FluentSQLite
final class RawView: Model {
typealias Database = SQLiteDatabase
typealias ID = Int
static let idKey: IDKey = \.id
var id: Int?
var name: String
init(id: Int?, name: String) {
self.id = id
self.name = name
}
}
// final class RawView: SQLiteModel {
// var id: Int?
// var name: String
// init(id: Int?, name: String) {
// self.id = id
// self.name = name
// }
// }
extension RawView: Content {}
extension RawView: Parameter {}
extension RawView: Migration {
static func prepare(on conn: SQLiteConnection) -> Future<Void> {
return conn.raw(
"""
create view RawView (id, name) as select * from Raw
"""
).run()
}
}
But use build-in query not work:
api.get("categories") { req in
return Category.query(on: req).all()
}
So some problem with my code use SQLiteMode where I can't find source code SQLiteModel for check. Some can help please. Sorry for my English.
I have some problem when create simple model:
and get by raw query:
everything OK. But when I create simple view:
and get by raw query:
It not working:
When try with:
It OK. It happen on Linux Ubuntu 18.04 and SQLite. But working very good on Ubuntu 18.0 and MySQL. What happening on my code. Sorry for my English.