Skip to content

Commit

Permalink
Added docs for relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhimanyuAryan committed Jul 7, 2022
1 parent 8a5a119 commit 400e17f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Relationships.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,32 @@ function Relationship(r1::Type{T}, r2::Type{R}; context::Module = @__MODULE__)::
getfield(context, Symbol(relationship_name(r1, r2)))
end

"""
Relationship!(r1::T, r2::R; context::Module)::AbstractModel where {T<:AbstractModel, R<:AbstractModel}
Relationship takes two AbstractModel types and
# Examples
```julia
julia> Base.@kwdef mutable struct Role <: AbstractModel
id::DbId = DbId()
name::String = ""
end
julia> Role(name::Union{String,Symbol}) = Role(name = string(name))
julia> Base.@kwdef mutable struct Permission <: AbstractModel
id::DbId = DbId()
name::String = ""
end
julia> Permission(name::Union{String,Symbol}) = Permission(name = string(name))
julia> Relationship!(user, role)
julia> isrelated(role, permission)
```
"""
function Relationship!(r1::T, r2::R; context::Module = @__MODULE__)::AbstractModel where {T<:AbstractModel, R<:AbstractModel}
relationship = Relationship(typeof(r1), typeof(r2); context = context)

Expand Down

0 comments on commit 400e17f

Please sign in to comment.