database_client.py

class database_client.DatabaseClient

A client which connects to Mongo and deals with Mongo database operations.

find_or_create_user(sender_id, name)

Find or crate a user in the database.

Either finds a user by sender_id, or creates that user in the database. Returns the user.

find_tool_by_id(tool_id)

Find a tool by searching on the id field.

find_tool_by_name(name)

Find a tool by searching on the name field.

find_user(field_name, field_value)

Find a user from a given field, allowing to search by any field.

find_user_by_sender_id(sender_id)

Find one user by using the sender_id as the search field.

get_all_available_tools()

Return all non checked out tools in the Tools database.

get_all_tools()

Return all tools in the Tools database.

get_all_users()

Return all users in the Users database.

update_tool(updated_tool)

Update a tool in the database.

Given an updated tool dictionary with the same _id, replace the old database entry with the new one

update_user(updated_user)

Update a user in the database.

Given an updated user dictionary with the same sender_id, replaces the old database entry with the new one

class database_client.User(sender_id, name)

The class sructure used for the User in the Mongo database.

class database_client.DatabaseClient

A client which connects to Mongo and deals with Mongo database operations.

find_or_create_user(sender_id, name)

Find or crate a user in the database.

Either finds a user by sender_id, or creates that user in the database. Returns the user.

find_tool_by_id(tool_id)

Find a tool by searching on the id field.

find_tool_by_name(name)

Find a tool by searching on the name field.

find_user(field_name, field_value)

Find a user from a given field, allowing to search by any field.

find_user_by_sender_id(sender_id)

Find one user by using the sender_id as the search field.

get_all_available_tools()

Return all non checked out tools in the Tools database.

get_all_tools()

Return all tools in the Tools database.

get_all_users()

Return all users in the Users database.

update_tool(updated_tool)

Update a tool in the database.

Given an updated tool dictionary with the same _id, replace the old database entry with the new one

update_user(updated_user)

Update a user in the database.

Given an updated user dictionary with the same sender_id, replaces the old database entry with the new one