We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
朋友们:你们好
在使用Perfect-CRUD的时候我想对model进行扩展一下功能,但是我遇到的问题是无法传递args,比如 //MARK :1 无法传递rest到对应的位置,所以来求助你们,希望能得到你们的帮助
public protocol SqlitInsterProtocol{ func insert() throws -> Int? func insert<Z: Decodable>( setKeys: KeyPath<Self, Z>, _ rest: PartialKeyPath<Self>...) throws -> Int? func insert<Z: Decodable>( ignoreKeys: KeyPath<Self, Z>, _ rest: PartialKeyPath<Self>...) throws -> Int? } extension SqlitInsterProtocol{ func insert() throws -> Int?{ do { let db = Database(configuration: try! SQLiteDatabaseConfiguration(Self.dbfile)) return try db.table(Self.self) .insert(self) .lastInsertId() }catch{ throw APIError(code: -1, msg: "error") } } func insert<Z: Decodable>( setKeys: KeyPath<Self, Z>, _ rest: PartialKeyPath<Self>...) throws -> Int?{ do { let db = Database(configuration: try! SQLiteDatabaseConfiguration(Self.dbfile)) // MARK :1 ignoreKeys +rest guard let id = try db.table(Self.self) .insert(self,setKeys:setKeys) .lastInsertId() else{ throw APIError(code: -1, msg: "error") } return id }catch{ throw APIError(code: -1, msg: "error") } } func insert<Z: Decodable>( ignoreKeys: KeyPath<Self, Z> , _ rest: PartialKeyPath<Self>...) throws -> Int{ do { let db = Database(configuration: try! SQLiteDatabaseConfiguration(Self.dbfile)) // MARK :1 ignoreKeys +rest guard let id = try db.table(Self.self) .insert(self,ignoreKeys:ignoreKeys) .lastInsertId() else{ throw APIError(code: -1, msg: "error") } return id }catch{ throw APIError(code: -1, msg: "error") } } } struct Cat: Codable,SqliteProtocol{ var id:Int = 0 var name:String="" } let cat = Cat(id:1,name:"kiter") try cat.inster(ignoreKeys: \Cat.id)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
朋友们:你们好
在使用Perfect-CRUD的时候我想对model进行扩展一下功能,但是我遇到的问题是无法传递args,比如 //MARK :1 无法传递rest到对应的位置,所以来求助你们,希望能得到你们的帮助
The text was updated successfully, but these errors were encountered: