From 400e17fd7e00b29780c8c168e80e623fddfe625c Mon Sep 17 00:00:00 2001 From: Abhi <8083613+AbhimanyuAryan@users.noreply.github.com> Date: Tue, 5 Jul 2022 14:01:21 +0530 Subject: [PATCH] Added docs for relationship --- src/Relationships.jl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Relationships.jl b/src/Relationships.jl index a5ae473..f24db53 100644 --- a/src/Relationships.jl +++ b/src/Relationships.jl @@ -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)