diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-02-27 22:57:06 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-02-27 22:57:06 +0100 |
commit | edb3ead976cd51ab6d627fe6b36bb9f0be8a17d3 (patch) | |
tree | 87c9e07d59c45e4c4c03fdb0fa7de83ac5449075 /planetwars-server/src/db/bots.rs | |
parent | da7164317681aeca442ccef6ed0a74ad1952f0bf (diff) | |
download | planetwars.dev-edb3ead976cd51ab6d627fe6b36bb9f0be8a17d3.tar.xz planetwars.dev-edb3ead976cd51ab6d627fe6b36bb9f0be8a17d3.zip |
retrieve opponent from bots database
Diffstat (limited to 'planetwars-server/src/db/bots.rs')
-rw-r--r-- | planetwars-server/src/db/bots.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/planetwars-server/src/db/bots.rs b/planetwars-server/src/db/bots.rs index baabd5a..d99a459 100644 --- a/planetwars-server/src/db/bots.rs +++ b/planetwars-server/src/db/bots.rs @@ -34,6 +34,10 @@ pub fn find_bots_by_owner(owner_id: i32, conn: &PgConnection) -> QueryResult<Vec .get_results(conn) } +pub fn find_bot_by_name(name: &str, conn: &PgConnection) -> QueryResult<Bot> { + bots::table.filter(bots::name.eq(name)).first(conn) +} + pub fn find_all_bots(conn: &PgConnection) -> QueryResult<Vec<Bot>> { // TODO: filter out bots that cannot be run (have no valid code bundle associated with them) bots::table.get_results(conn) |