Define Instance::get_locals()

This commit is contained in:
Kitaiti Makoto 2021-09-12 03:57:12 +09:00
parent 037d670fb7
commit 1ed60537cf

View file

@ -79,6 +79,13 @@ impl Instance {
*LOCAL_INSTANCE.write().unwrap() = Instance::get_local_uncached(conn).ok(); *LOCAL_INSTANCE.write().unwrap() = Instance::get_local_uncached(conn).ok();
} }
pub fn get_locals(conn: &Connection) -> Result<Vec<Instance>> {
instances::table
.filter(instances::local.eq(true))
.load::<Instance>(conn)
.map_err(Error::from)
}
pub fn get_remotes(conn: &Connection) -> Result<Vec<Instance>> { pub fn get_remotes(conn: &Connection) -> Result<Vec<Instance>> {
instances::table instances::table
.filter(instances::local.eq(false)) .filter(instances::local.eq(false))