Codegen mod.rs include prelude

This commit is contained in:
Billy Chan 2021-08-17 12:41:34 +08:00 committed by Chris Tsang
parent 2580f65696
commit aea4ec2d54
2 changed files with 10 additions and 1 deletions

View File

@ -44,11 +44,18 @@ impl EntityWriter {
pub fn write_mod(&self) -> OutputFile { pub fn write_mod(&self) -> OutputFile {
let mut lines = Vec::new(); let mut lines = Vec::new();
Self::write_doc_comment(&mut lines); Self::write_doc_comment(&mut lines);
let code_blocks = self let code_blocks: Vec<TokenStream> = self
.entities .entities
.iter() .iter()
.map(|entity| Self::gen_mod(entity)) .map(|entity| Self::gen_mod(entity))
.collect(); .collect();
Self::write(
&mut lines,
vec![quote! {
pub mod prelude;
}],
);
lines.push("".to_owned());
Self::write(&mut lines, code_blocks); Self::write(&mut lines, code_blocks);
OutputFile { OutputFile {
name: "mod.rs".to_owned(), name: "mod.rs".to_owned(),

View File

@ -1,5 +1,7 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 //! SeaORM Entity. Generated by sea-orm-codegen 0.1.0
pub mod prelude;
pub mod cake; pub mod cake;
pub mod cake_filling; pub mod cake_filling;
pub mod filling; pub mod filling;