User

DearDiary.get_userFunction
get_user(username::AbstractString)::Optional{User}

Get an User by username.

Arguments

  • username::AbstractString: The username of the user to query.

Returns

An User object. If the record does not exist, return nothing.

source
get_user(id::Integer)::Optional{User}

Get an User by id.

Arguments

  • id::Integer: The id of the user to query.

Returns

An User object. If the record does not exist, return nothing.

source
DearDiary.create_userFunction
create_user(first_name::AbstractString, last_name::AbstractString, username::AbstractString, password::AbstractString)::Tuple{Optional{<:Int64},UpsertResult}

Create an User.

Arguments

  • first_name::AbstractString: The first name of the user.
  • last_name::AbstractString: The last name of the user.
  • username::AbstractString: The username of the user.
  • password::AbstractString: The password of the user.

Returns

An UpsertResult. Created if the record was successfully created, Duplicate if the record already exists, Unprocessable if the record violates a constraint, and Error if an error occurred while creating the record.

source
DearDiary.update_userFunction
update_user(id::Integer, first_name::Optional{AbstractString}, last_name::Optional{AbstractString}, password::Optional{AbstractString}, is_admin::Optional{Bool})::UpsertResult

Update an User.

Arguments

  • id::Integer: The id of the user to update.
  • first_name::Optional{AbstractString}: The new first name of the user.
  • last_name::Optional{AbstractString}: The new last name of the user.
  • password::Optional{AbstractString}: The new password of the user.
  • is_admin::Optional{Bool}: The new admin status of the user.

Returns

An UpsertResult. Updated if the record was successfully updated (or no fields were changed), Unprocessable if the record violates a constraint or if no fields were provided to update, and Error if an error occurred while updating the record.

source
DearDiary.delete_userFunction
delete_user(id::Integer)::Bool

Delete an User. Also deletes all associated UserPermission.

Arguments

  • id::Integer: The id of the user to delete.

Returns

true if the record was successfully deleted, false otherwise.

source