Z.Urls (Portico/Z v0.1.0)

Context module for working with URL shortening

Link to this section Summary

Functions

Delete a URL by identifier

Retrieve a URL by identifier

Save a URL to the database and get back a ZSchemas.Url with a unique short-code identifier.

Link to this section Functions

Link to this function

delete_url(identifier)

Specs

delete_url(identifier :: String.t()) ::
  {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()} | {:error, atom()}

Delete a URL by identifier

Link to this function

get_url(identifier)

Specs

get_url(identifier :: String.t()) :: Ecto.Schema.t() | nil

Retrieve a URL by identifier

Link to this function

insert_url(url, args \\ [])

Specs

insert_url(url :: String.t(), args :: Keyword.t()) ::
  {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}

Save a URL to the database and get back a ZSchemas.Url with a unique short-code identifier.

URL identifiers are re-used to save on precious database space :)

args will be passed to the identifier generation function, which is Utility.Crypto.letter_hash/2.