feat: Add get_all method to list all db objects based on the object model

This commit is contained in:
Mahmoud-Emad
2025-05-21 09:13:58 +03:00
parent bd36d6bda0
commit 4c0c7be574
7 changed files with 225 additions and 87 deletions

View File

@@ -1,9 +1,9 @@
use chrono::{DateTime, Utc};
use heromodels_core::BaseModelData;
use heromodels_derive::model;
use serde::{Deserialize, Serialize};
use rhai_autobind_macros::rhai_model_export;
use rhai::{CustomType, TypeBuilder};
use rhai_autobind_macros::rhai_model_export;
use serde::{Deserialize, Serialize};
/// Represents the status of an attendee for an event
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@@ -60,7 +60,12 @@ pub struct Event {
impl Event {
/// Creates a new event
pub fn new(id: String, title: impl ToString, start_time: DateTime<Utc>, end_time: DateTime<Utc>) -> Self {
pub fn new(
id: String,
title: impl ToString,
start_time: DateTime<Utc>,
end_time: DateTime<Utc>,
) -> Self {
Self {
id,
title: title.to_string(),
@@ -108,7 +113,11 @@ impl Event {
}
/// Reschedules the event to new start and end times
pub fn reschedule(mut self, new_start_time: DateTime<Utc>, new_end_time: DateTime<Utc>) -> Self {
pub fn reschedule(
mut self,
new_start_time: DateTime<Utc>,
new_end_time: DateTime<Utc>,
) -> Self {
// Basic validation: end_time should be after start_time
if new_end_time > new_start_time {
self.start_time = new_start_time;