Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 91955a18 authored by rafliesa's avatar rafliesa
Browse files

Implement add function in Subscriber repository.

parent 0b6aec56
No related branches found
No related tags found
No related merge requests found
use dashmap::DashMap;
use lazy_static::lazy_static;
use crate::model::subscriber::Subscriber;
use crate::model::subscriber::{self, Subscriber};
use super::product;
lazy_static! {
static ref SUBSCRIBERS: DashMap<String, DashMap<String, Subscriber>> = DashMap :: new();
......@@ -9,4 +11,14 @@ lazy_static! {
pub struct SubscriberRepository;
impl SubscriberRepository {
pub fn add(product_type: &str, subscriber: Subscriber) -> Subscriber {
let subscriber_value = subscriber.clone();
if SUBSCRIBERS.get(product_type).is_none() {
SUBSCRIBERS.insert(String::from(product_type), DashMap::new());
};
SUBSCRIBERS.get(product_type).unwrap()
.insert(subscriber_value.url.clone(), subscriber_value);
return subscriber;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment