db new models

This commit is contained in:
timurgordon
2025-06-18 01:56:24 +03:00
parent 00c4e6a1eb
commit 6b3cbfc4b2
9 changed files with 602 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
use heromodels_core::BaseModelData;
use heromodels_derive::model;
// Temporarily removed to fix compilation issues
// use rhai_autobind_macros::rhai_model_export;
use rhai::{CustomType, TypeBuilder};
use serde::{Deserialize, Serialize};
/// Represents an event in a contact
#[model]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, CustomType)]
pub struct Access {
/// Base model data
pub base_data: BaseModelData,
#[index]
pub object_id: u32,
pub circle_id: u32,
pub contact_id: u32,
pub group_id: u32,
pub expires_at: Option<u64>,
}
impl Access {
pub fn new() -> Self {
Access {
base_data: BaseModelData::new(),
object_id: 0,
circle_id: 0,
contact_id: 0,
group_id: 0,
expires_at: None,
}
}
pub fn object_id(mut self, object_id: u32) -> Self {
self.object_id = object_id;
self
}
pub fn contact_id(mut self, contact_id: u32) -> Self {
self.contact_id = contact_id;
self
}
pub fn group_id(mut self, group_id: u32) -> Self {
self.group_id = group_id;
self
}
pub fn circle_id(mut self, circle_id: u32) -> Self {
self.circle_id = circle_id;
self
}
pub fn expires_at(mut self, expires_at: Option<u64>) -> Self {
self.expires_at = expires_at;
self
}
}