-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dfbdeb
commit e81c007
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use super::{collect_messages, Result}; | ||
use rrgen::RRgen; | ||
use serde_json::json; | ||
|
||
const DEFAULT_SEEDER_T: &str = include_str!("templates/seeder/default.t"); | ||
|
||
pub fn generate(rrgen: &RRgen, name: String) -> Result<String> { | ||
let vars = json!({"name": name}); | ||
let res = rrgen.generate(DEFAULT_SEEDER_T, &vars)?; | ||
|
||
Ok(collect_messages(vec![res])) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% set module_name = name | snake_case -%} | ||
{% set struct_name = module_name | pascal_case -%} | ||
use loco_rs::prelude::*; | ||
|
||
pub struct {{struct_name}}Seeder; | ||
|
||
impl Seeder for {{struct_name}}Seeder { | ||
fn name(&self) -> String { | ||
"{{struct_name}}Seeder".to_string() | ||
} | ||
|
||
async fn seed(&self, conn: &DatabaseConnection) -> AppResult<()> { | ||
todo!() | ||
} | ||
} |