use lunar_lib::database::{DbHandle, EntryIdExt, TransactionError};

use crate::{
    database::LibraryDb,
    library::artist::{Artist, ArtistId},
};

impl Artist {
    pub fn db_find_by_name(name: impl AsRef<str>) -> Result<Option<Self>, TransactionError>
    where
        Self: 'static,
    {
        let db = DbHandle::<LibraryDb>::open().unwrap();
        ArtistId::new(name.as_ref()).db_get(&db)
    }
}
