简体   繁体   English

参数标签'(content :)'不匹配任何可用的重载,swift,vapor,蒸气中残留的,使用postgresql

[英]Argument labels '(content:)' do not match any available overloads, swift ,vapor,rest in vapor ,using postgresql

Error Argument labels '(content:)' do not match any available overloads.using postgresql while the rest in vapor to get json representable.The syntax for model controller is as followed, meaning for content in database 错误参数标签'{content:}'与任何可用的重载都不匹配。使用postgresql,而其余的蒸气以可表示json的形式表示。模型控制器的语法如下,这意味着数据库中的内容

import Foundation
import Vapor
import FluentProvider
import PostgreSQLProvider


final class dataPointStorage: Model, JSONRepresentable, NodeRepresentable {

//  var _data: dataPointProtocol?
//    var _data:[dataPointProtocol] = []
    let storage = Storage()
    var id: Node?
    var name:String
    var displayName:String
    var content:String
//    let temp = dataPointStorage()


    init(node:Node ,content: String?, displayName:String, name:String) {
        self.id = nil
        self.displayName = displayName
        self.name = name
    }

        static let idKey = "id"
        static let contentKey = "content"



    func forDataBase() {


        let array:[berichtDataPoint] = [intDataPoint(), boolDataPoint(), doubleDataPoint()]

        let _ = array[0] as! intDataPoint
        let _ = array[1] as! doubleDataPoint


        for point in array {

            switch point {
            case is  intDataPoint:
                print("int")
            case is doubleDataPoint:
                print("double")
            case is boolDataPoint:
                print("bool")
            default:
                print("error")
            }
        }

    }

  func makeRow() throws -> Row {
        var row = Row()
        try row.set("id", id)
        try row.set("displayName", displayName)
        try row.set("name", name)
        return row
    }

    init(row: Row) throws {
        id = try row.get("id")
        displayName = try row.get("displayName")
        name = try row.get("name")
    }

    func makeNode(context: Context) throws -> Node {
        return try Node(node: [
            "id": id,
            "displayName": displayName,
            "name": name
            ])
    }
}

extension dataPointStorage: Preparation {
    static func prepare(_ database: Database) throws {
        try database.create(self) { dataPointStorage in
            dataPointStorage.id()
            dataPointStorage.string("displayName")
            dataPointStorage.string("name")
            dataPointStorage.string("content")

        }
    }

    static func revert(_ database: Database) throws {
        try database.delete(dataPointStorage)
    }
}

extension dataPointStorage: JSONConvertible {
    convenience init(json: JSON) throws {
        try self.init(
       error here¶¶¶ content: json.get(dataPointStorage.contentKey)¶¶¶¶ error
        )
    }

    func makeJSON() throws -> JSON {
        var json = JSON()
        try json.set("id", id)
        try json.set("name", name)
        try json.set("displaName", displayName)
        try json.set("content", Content)

        return json
    }
}

I am following the general context of rest in vapor as JSON representable but didn't get the reason of this simple error to solve. 我将蒸气中的其余部分作为JSON可表示的一般上下文进行跟踪,但没有得到解决此简单错误的原因。

It looks like you are trying to call this init? 看来您正在尝试将其称为init?

init(node:Node ,content: String?, displayName:String, name:String)

If that is the case, you need to pass in the rest of the arguments because there are no default values available for them: 在这种情况下,您需要传入其余参数,因为没有可用的默认值:

convenience init(json: JSON) throws {
    try self.init(
        node: <VALUE>,
        content: json.get(dataPointStorage.contentKey),
        displayName: <VALUE>,
        name: <VALULE>
    )
}

That will fix your problem. 那将解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift,错误(参数标签&#39;(node :)&#39;不匹配任何可用的重载),蒸气中静止,模型控制器 - Swift,error(Argument labels '(node:)' do not match any available overloads),rest in vapor,model Controller 快速迁移:参数标签&#39;(_ :)&#39;与任何可用的重载都不匹配 - Swift migration: Argument labels '(_:)' do not match any available overloads 迅速3错误:参数标签&#39;(count :)&#39;与任何可用的重载都不匹配 - swift 3 error : Argument labels '(count:)' do not match any available overloads 参数标签与任何可用的重载都不匹配 - Argument labels do not match any available overloads swift Swift UICollectionViewLayoutAttributes参数标签&#39;(_ :)&#39;与任何可用的重载都不匹配? - Swift UICollectionViewLayoutAttributes Argument labels '(_:)' do not match any available overloads? swift 3错误:参数标签'(_ :)'与任何可用的重载都不匹配 - swift 3 error : Argument labels '(_:)' do not match any available overloads Swift CGPoint参数标签&#39;(_ :, _ :)&#39;与任何可用的重载都不匹配 - Swift CGPoint Argument labels '(_:, _:)' do not match any available overloads Swift Newbie Argument标签&#39;(_ :, IndexPath :)&#39;与任何可用的重载都不匹配 - Swift Newbie Argument labels '(_:, IndexPath:)' do not match any available overloads Swift 2错误:参数标签&#39;(value :)&#39;与任何可用的重载都不匹配 - Swift 2 Error: Argument labels '(value:)' do not match any available overloads swift cgsize错误参数标签&#39;(_ :, _ :)&#39;与任何可用的重载都不匹配 - swift cgsize error Argument labels '(_:, _:)' do not match any available overloads
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM