pique/_experiments/2024-03-02-database-benchmark/src/data.rs

27 lines
676 B
Rust
Raw Permalink Normal View History

use rand::{
distributions::{Alphanumeric, DistString},
thread_rng,
};
use sea_orm::ActiveValue;
pub fn random_entities(count: usize, text_length: usize) -> Vec<entity::page::ActiveModel> {
let mut pages = vec![];
let mut rng = thread_rng();
for idx in 0..count {
let _id = idx as i32;
let title = "dummy_title";
let text = Alphanumeric.sample_string(&mut rng, text_length);
pages.push(entity::page::ActiveModel {
external_id: ActiveValue::Set(1),
title: ActiveValue::Set(title.to_owned()),
text: ActiveValue::Set(text),
..Default::default()
});
}
pages
}