frost.server.storage package¶
Submodules¶
frost.server.storage.base module¶
-
class
frost.server.storage.base.
Base
¶ Bases:
object
The base model for data storage.
-
classmethod
add
(item: Any) → str¶ Adds an item under the given specific table.
- Parameters
item (Any) – The item to add
- Raises
KeyError – If an item under a given ID already exists
- Returns
The ID of the given item stored under the given table.
- Return type
str
-
static
commit
(data: Dict[str, Any]) → None¶ Commits and saves the data.
- Parameters
data (Dict[str, Any]) – The data to be saved
-
static
data
() → Dict[str, Any]¶ Gets the contents of the saved data.
- Returns
The contents of the saved data
- Return type
Dict[str, Any]
-
classmethod
entries
() → Dict[str, Any]¶ Get the entries under the specified table.
- Returns
The entries under the specified table
- Return type
Dict[str, Any]
-
classmethod
search
(item: Any) → Any¶ Searches the saved data for a specific item.
- Parameters
item (Any) – The item to search for
- Returns
The data found under the specific item, returns None if not found
- Return type
Any
-
classmethod
update
(item: Any) → None¶ Updates the given item’s data. Does not care if the item already exists.
- Parameters
item (Any) – The item to update
-
classmethod
-
class
frost.server.storage.base.
Unique
(data: Any)¶ Bases:
object
Ensures that the data stored is unique within its table.
- Parameters
data (Any) – The unique data to be stored in a table
frost.server.storage.defaults module¶
frost.server.storage.exceptions module¶
-
exception
frost.server.storage.exceptions.
DuplicateValueError
¶ Bases:
Exception
There was a duplicate value trying to be saved in a new entry within a specific table.
frost.server.storage.models module¶
-
class
frost.server.storage.models.
Message
(message: str, timestamp: str, from_user: Dict[str, str], id_: str = None)¶ Bases:
frost.server.storage.base.Base
The message model (
__tablename__ = 'messages'
)- Parameters
message (str) – The message sent from a user
timestamp (str) – The timestamp the message was sent
from_user (Dict[str, str]) – Information about who sent the message
id (str, optional) – The message’s ID, autofilled by
frost.server.storage.base._get_id()
if None
-
class
frost.server.storage.models.
Room
(name: str, owner_id: str, id_: str = None, members: List[Dict[str, str]] = [])¶ Bases:
frost.server.storage.base.Base
The room model (
__tablename__ = 'rooms'
)- Parameters
name (str) – The room’s name
owner_id (str) – The ID of the owner of the room
id (str, optional) – The room’s ID, autofilled by
frost.server.storage.base._get_id()
if Nonemembers (list, optional) – The members of the room, defaults to
[]
-
class
frost.server.storage.models.
User
(username: str, password: str, id_: str = None, token: str = None)¶ Bases:
frost.server.storage.base.Base
The user model (
__tablename__ = 'users'
)- Parameters
username (str) – The user’s username
password (str) – The user’s password
id (str, optional) – The user’s ID, autofilled by
frost.server.storage.base._get_id()
if Nonetoken (str, optional) – The user’s token, defaults to None
Module contents¶
-
class
frost.server.storage.
Base
¶ Bases:
object
The base model for data storage.
-
classmethod
add
(item: Any) → str¶ Adds an item under the given specific table.
- Parameters
item (Any) – The item to add
- Raises
KeyError – If an item under a given ID already exists
- Returns
The ID of the given item stored under the given table.
- Return type
str
-
static
commit
(data: Dict[str, Any]) → None¶ Commits and saves the data.
- Parameters
data (Dict[str, Any]) – The data to be saved
-
static
data
() → Dict[str, Any]¶ Gets the contents of the saved data.
- Returns
The contents of the saved data
- Return type
Dict[str, Any]
-
classmethod
entries
() → Dict[str, Any]¶ Get the entries under the specified table.
- Returns
The entries under the specified table
- Return type
Dict[str, Any]
-
classmethod
search
(item: Any) → Any¶ Searches the saved data for a specific item.
- Parameters
item (Any) – The item to search for
- Returns
The data found under the specific item, returns None if not found
- Return type
Any
-
classmethod
update
(item: Any) → None¶ Updates the given item’s data. Does not care if the item already exists.
- Parameters
item (Any) – The item to update
-
classmethod
-
class
frost.server.storage.
User
(username: str, password: str, id_: str = None, token: str = None)¶ Bases:
frost.server.storage.base.Base
The user model (
__tablename__ = 'users'
)- Parameters
username (str) – The user’s username
password (str) – The user’s password
id (str, optional) – The user’s ID, autofilled by
frost.server.storage.base._get_id()
if Nonetoken (str, optional) – The user’s token, defaults to None
-
class
frost.server.storage.
Room
(name: str, owner_id: str, id_: str = None, members: List[Dict[str, str]] = [])¶ Bases:
frost.server.storage.base.Base
The room model (
__tablename__ = 'rooms'
)- Parameters
name (str) – The room’s name
owner_id (str) – The ID of the owner of the room
id (str, optional) – The room’s ID, autofilled by
frost.server.storage.base._get_id()
if Nonemembers (list, optional) – The members of the room, defaults to
[]
-
class
frost.server.storage.
Message
(message: str, timestamp: str, from_user: Dict[str, str], id_: str = None)¶ Bases:
frost.server.storage.base.Base
The message model (
__tablename__ = 'messages'
)- Parameters
message (str) – The message sent from a user
timestamp (str) – The timestamp the message was sent
from_user (Dict[str, str]) – Information about who sent the message
id (str, optional) – The message’s ID, autofilled by
frost.server.storage.base._get_id()
if None
-
exception
frost.server.storage.
DuplicateValueError
¶ Bases:
Exception
There was a duplicate value trying to be saved in a new entry within a specific table.