refactors claims unit tests
This commit is contained in:
@@ -22,6 +22,25 @@ pub struct Player {
|
||||
pub pp: i32,
|
||||
}
|
||||
|
||||
pub struct Players<'q>(pub &'q DbConnection);
|
||||
|
||||
impl<'q> Players<'q> {
|
||||
|
||||
pub fn all(&self) -> QueryResult<Vec<Player>> {
|
||||
players::table
|
||||
.load(self.0)
|
||||
}
|
||||
|
||||
pub fn add(&self, name: &str, wealth: f32) -> QueryResult<Player> {
|
||||
diesel::insert_into(players::table)
|
||||
.values(&NewPlayer::create(name, wealth))
|
||||
.execute(self.0)?;
|
||||
players::table
|
||||
.order(players::dsl::id.desc())
|
||||
.first(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AsPlayer<'q>(pub &'q DbConnection, pub i32);
|
||||
|
||||
impl<'q> AsPlayer<'q> {
|
||||
|
||||
Reference in New Issue
Block a user