insert battle
This commit is contained in:
parent
b0c80472e6
commit
9419b1cc3d
@ -329,7 +329,6 @@ impl Battle {
|
||||
}
|
||||
|
||||
|
||||
// add the ability
|
||||
// add client function call
|
||||
// check for cryp ability ownership
|
||||
// check for battle participation
|
||||
@ -358,6 +357,25 @@ pub fn battle_ability(params: BattleAbilityParams, tx: &mut Transaction, account
|
||||
return battle_write(battle, tx);
|
||||
}
|
||||
|
||||
pub fn battle_new(battle: Battle, tx: &mut Transaction) -> Result<Battle, Error> {
|
||||
let battle_bytes = to_vec(&battle)?;
|
||||
|
||||
let query = "
|
||||
INSERT INTO battles (id, data)
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING id, account;
|
||||
";
|
||||
|
||||
let result = tx
|
||||
.query(query, &[&battle_bytes, &battle.id])?;
|
||||
|
||||
let _returned = result.iter().next().expect("no row returned");
|
||||
|
||||
println!("{:?} wrote battle", battle.id);
|
||||
|
||||
return Ok(battle);
|
||||
}
|
||||
|
||||
pub fn battle_write(battle: Battle, tx: &mut Transaction) -> Result<Battle, Error> {
|
||||
let battle_bytes = to_vec(&battle)?;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user