User
DearDiary.get_user — Function
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.
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.
DearDiary.get_users — Function
DearDiary.create_user — Function
create_user(first_name::AbstractString, last_name::AbstractString, username::AbstractString, password::AbstractString)::NamedTuple{id::Optional{<:Int64},status::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
- The created user ID. If an error occurs,
nothingis returned. - An
UpsertResult.Createdif the record was successfully created,Duplicateif the record already exists,Unprocessableif the record violates a constraint, andErrorif an error occurred while creating the record.
DearDiary.update_user — Function
update_user(id::Integer, first_name::Optional{AbstractString}, last_name::Optional{AbstractString}, password::Optional{AbstractString}, is_admin::Optional{Bool})::UpsertResultUpdate 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.
DearDiary.delete_user — Function
delete_user(id::Integer)::BoolDelete 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.