Group Group Group Group Group Group Group Group Group

How to save Multidimensional Array?

#1

Ive been trying to parse JSON which contains multidimensional array of objects. Vapor sends me an error when im trying to post JSON, error description:

[ ERROR ] PostgreSQLError.server.error.array_recv: wrong element type (ErrorMiddleware.swift:26)
Here is the Model:

import FluentPostgreSQL
import Vapor

final class Category: Codable {
    var id: Int?
    var options: Options
    var questions: [[Question]]

    init(options: Options, questions: [[Question]]) {
        self.options = options
        self.questions = questions
    }
}


extension Category: Content {}
extension Category: PostgreSQLModel{}
extension Category: Migration{}
extension Category: Parameter {}
#2

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

#3

@chem1x as discussed on Discord, I think this is because Postgres can’t handle multidimensional arrays when you try and save it into the database so you either need to flatten it or move it into a separate table