Strapping.jl
Strapping.jl copied to clipboard
How to `deconstruct` structs with arrays?
I've tried Strapping.jl
on the following example:
struct Person
id::Int64
firstname::String
lastname::String
end
struct Club
id::Int64
name::String
members::Array{Person}
end
StructTypes.StructType(::Type{Person}) = StructTypes.Struct()
StructTypes.idproperty(::Type{Person}) = :id
StructTypes.StructType(::Type{Club}) = StructTypes.Struct()
StructTypes.idproperty(::Type{Club}) = :id
p1 = Person(1, "John", "Smith")
p2 = Person(2, "Mary", "Miller")
c1 = Club(1, "chess club", [p1, p2])
club_table = Strapping.deconstruct(c1)
Applying deconstruct
on c1
I expected to get all information within this struct in a tabular form. But somehow deconstruct
cannot cope with the array within this struct. I'm getting the following results:
julia> fc = first(club_table)
Strapping.DeconstructedRow{Club}: (id = 1, name = "chess club", members_id = 1, members_firstname = "John", members_lastname = "Smith")
Only the first member of the club (John Smith) es retrieved. How can I get all the data within c1
in a tabular form in order to store it in a relational database?