23 lines
757 B
Rust
23 lines
757 B
Rust
|
use crate::models::*;
|
||
|
use diesel::prelude::*;
|
||
|
use crate::database::establish_connection;
|
||
|
|
||
|
//get_npc_here trae da base de datos o npc polo nome e a pegatina da sala actual
|
||
|
pub fn get_npc_here(pegatina: String, nome: String) -> Result<Rnpc, diesel::result::Error> {
|
||
|
use crate::schema::npc::dsl::*;
|
||
|
let conn = &mut establish_connection();
|
||
|
npc
|
||
|
.filter(location.eq(pegatina))
|
||
|
.filter(nombre.eq(nome))
|
||
|
.first(conn)
|
||
|
}
|
||
|
|
||
|
// get_npcs trae da base de datos todos os npcs de unha localización
|
||
|
pub fn get_npcs(pegatina: String) -> Result<Vec<Rnpc>, diesel::result::Error> {
|
||
|
use crate::schema::npc::dsl::*;
|
||
|
let conn = &mut establish_connection();
|
||
|
npc
|
||
|
.filter(location.eq(pegatina))
|
||
|
.get_results(conn)
|
||
|
}
|