comment_app_backend 0.1.3

Serves comments through Restful APIs
Documentation
// downvote.rs
// downvote specific functions are implemented here

use serde_derive::{Serialize, Deserialize};
use chrono::prelude::*;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Downvote {

    #[serde(default = "String::new")]
    pub comment_id: String,  // comment_id or reply_id

    #[serde(default = "String::new")]
    pub user_id: String,

    #[serde(default = "String::new")]
    pub remarks: String,

    #[serde(default = "String::new")]
    pub created_on: String,

    #[serde(default = "String::new")]
    pub updated_on: String,

    #[serde(default = "String::new")]
    pub deleted_on: String,
}

impl PartialEq for Downvote {
    fn eq(&self, other: &Self) -> bool {
        (self.comment_id == other.comment_id) &&
        (self.user_id == other.user_id)
    }
}

impl Eq for Downvote {}   // no methods implemented

pub fn assign_created_date(downvote: &mut Downvote) {
    downvote.created_on = Local::now().to_string();
}
pub fn assign_updated_date(downvote: &mut Downvote) {
    downvote.updated_on = Local::now().to_string();
}
pub fn assign_deleted_date(downvote: &mut Downvote) {
    downvote.deleted_on = Local::now().to_string();
}
pub fn timestamp_now() -> String {
    Local::now().to_string()
}