Best way to make has_many/belongs_to relation for structs?

How about:

julia> abstract type AbstractPost end

julia> struct User{V <: Vector{<:AbstractPost}}
         posts::V
       end

julia> struct Post <: AbstractPost
         user::User{Vector{Post}}
       end

julia> u1 = User(Post[])
User{Array{Post,1}}(Post[])

julia> p1 = Post(u1)
Post(User{Array{Post,1}}(Post[]))

julia> push!(u1.posts, p1)
1-element Array{Post,1}:
 Post(User{Array{Post,1}}(Post[Post(#= circular reference @-3 =#)]))
2 Likes