nexus_common/models/follow/
following.rs1use crate::db::{queries, RedisOps};
2use async_trait::async_trait;
3use neo4rs::Query;
4use serde::{Deserialize, Serialize};
5use utoipa::ToSchema;
6
7use super::traits::UserFollows;
8
9#[derive(Serialize, Deserialize, ToSchema, Default, Debug)]
10pub struct Following(pub Vec<String>);
11
12impl AsRef<[String]> for Following {
13 fn as_ref(&self) -> &[String] {
14 &self.0
15 }
16}
17
18#[async_trait]
19impl RedisOps for Following {}
20
21impl UserFollows for Following {
22 fn from_vec(vec: Vec<String>) -> Self {
23 Self(vec)
24 }
25
26 fn get_query(user_id: &str, skip: Option<usize>, limit: Option<usize>) -> Query {
27 queries::get::get_user_following(user_id, skip, limit)
28 }
29
30 fn get_ids_field_name() -> &'static str {
31 "following_ids"
32 }
33}