View Source YaBTT.Schema.Connection (YaBTT v0.1.5)

The schema for the connections table.

A torrent can have many peers, and a peer can be connected to many torrents. This schema is used to store the primary keys as a foreign key from the torrents and peers tables.

At the same time, this table is also responsible for maintaining the status of the link. Including uploaded',downloaded', left and event.

Link to this section Summary

Functions

A changeset to validate if the status of the connection is valid. This torrent_id and peer_id are used to connect with the torrents and peers tables.

Link to this section Types

@type changeset_t() :: Ecto.Changeset.t(t())
@type connect() :: {term(), term()}
@type params() :: map()
@type t() :: %YaBTT.Schema.Connection{
  __meta__: term(),
  completed: term(),
  downloaded: term(),
  id: term(),
  left: term(),
  peer: term(),
  peer_id: term(),
  started: term(),
  torrent: term(),
  torrent_info_hash: term(),
  uploaded: term()
}

Link to this section Functions

Link to this function

changeset(connection, params, arg)

View Source
@spec changeset(changeset_t() | t(), params(), connect()) :: changeset_t()

A changeset to validate if the status of the connection is valid. This torrent_id and peer_id are used to connect with the torrents and peers tables.

parameters

Parameters

  • connection: the changeset or YaBTT.Schema.Connection
  • params: the request parameters
  • connect: the torrent_id and peer_id to connect with the torrents and peers tables

examples

Examples

iex> alias YaBTT.Schema.Connection
iex> params = %{"uploaded" => "121", "downloaded" => "41421", "left" => "0", "event" => "started"}
iex> Connection.changeset(%Connection{}, params, {1, 1})