Struct quad_diesel::models::Account
[−]
[src]
pub struct Account { pub id: i32, pub username: String, pub balance: i32, }
The account structure.
Fields
id: i32
The unique identifier of the account.
username: String
The unique username of the account.
balance: i32
The amount of quadbucks in the account.
Methods
impl Account
[src]
fn all(conn: &SqliteConnection) -> Result<Vec<Account>, ResultError>
Return all the accounts in the database.
fn find_by_username(conn: &SqliteConnection,
username: &str)
-> Result<Account, ResultError>
username: &str)
-> Result<Account, ResultError>
Find an Account
in the database by the username.
fn create_from(conn: &SqliteConnection,
new_account: NewAccount)
-> Result<Account, ResultError>
new_account: NewAccount)
-> Result<Account, ResultError>
Create an Account
from a NewAccount
. Note this might error with a unique constraint
error if the account with this username already exists.
fn save(&mut self, conn: &SqliteConnection) -> Result<(), ResultError>
Save all changes back to the database.
fn transfer(&mut self,
conn: &SqliteConnection,
other: &mut Account,
amount: i32)
-> Result<(), ResultError>
conn: &SqliteConnection,
other: &mut Account,
amount: i32)
-> Result<(), ResultError>
Transfer some amount
quadbucks from this account to another account.