development_postgress #11

Merged
lee merged 11 commits from development_postgress into main 2025-07-31 13:32:49 +00:00
2 changed files with 16 additions and 0 deletions
Showing only changes of commit 87a5ae67c7 - Show all commits

View File

@ -123,6 +123,11 @@ pub fn model(_attr: TokenStream, item: TokenStream) -> TokenStream {
} }
}; };
let indexed_field_names = indexed_fields
.iter()
.map(|f| f.0.to_string())
.collect::<Vec<_>>();
let model_impl = quote! { let model_impl = quote! {
impl heromodels_core::Model for #struct_name { impl heromodels_core::Model for #struct_name {
fn db_prefix() -> &'static str { fn db_prefix() -> &'static str {
@ -137,6 +142,12 @@ pub fn model(_attr: TokenStream, item: TokenStream) -> TokenStream {
&mut self.base_data &mut self.base_data
} }
fn indexed_fields() -> Vec<&'static str> {
vec![
#(#indexed_field_names),*
]
}
#db_keys_impl #db_keys_impl
} }
}; };

View File

@ -58,6 +58,11 @@ pub trait Model:
Vec::new() Vec::new()
} }
/// Return a list of field names which have an index applied.
fn indexed_fields() -> Vec<&'static str> {
Vec::new()
}
/// Get the unique ID for this model /// Get the unique ID for this model
fn get_id(&self) -> u32; fn get_id(&self) -> u32;