mod create;
mod delete;
pub(super) mod enums;
mod imports;
mod order;
mod read;
mod root;
mod sql;
mod update;
use super::model::Model;
use crate::database::introspection::Schema;
use crate::generators::layout::File;
use crate::generators::ownership::Ownership;
pub fn files(model: &Model, schema: &Schema) -> Vec<File> {
let mut files = vec![
generated("mod.rs", root::render(model, schema)),
generated("read.rs", read::render(model, schema)),
];
if !model.view {
files.push(generated("create.rs", create::render(model)));
files.push(generated("update.rs", update::render(model, schema)));
files.push(generated("delete.rs", delete::render(model, schema)));
}
if model.actix {
files.push(generated("routes.rs", super::actix::render(model, schema)));
}
files
}
fn generated(name: &'static str, contents: String) -> File {
File {
name,
ownership: Ownership::Generated,
contents,
}
}