Skip to content

Conversation

@Xiaozonglin
Copy link
Member

@Xiaozonglin Xiaozonglin commented Nov 6, 2025

我之前没弄分支,所以...之前的commit都跟过来了
image
image
image

Xiaozonglin and others added 30 commits October 27, 2025 21:14
需要为 users 表增加 feed_token 字段(nullable text/varchar)。
(无语住了
现在只要是没有被禁的用户都可以用自己的token订阅
日志含 subscriber id/name、author id/name、时间戳(不记录 token),用现有的 tracing 记录器输出。
@Xiaozonglin
Copy link
Member Author

Xiaozonglin commented Nov 6, 2025

需要在reports数据表中添加likes列(text),将以数组的形式存储点赞的用户
@Reverier-Xu

Copy link
Member

@Reverier-Xu Reverier-Xu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

挠头,我觉得ai vibe coding还是太早了,要不再学一学?

sea-orm ref https://www.sea-ql.org/SeaORM/docs/generate-entity/column-types/

pub week: i32,
#[sea_orm(column_type = "Text", nullable)]
pub content: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要这么存likes,rust sea-orm有json相关的序列化功能,包括后面手搓的序列化代码也是不必要的

// Perform an atomic update of the likes column and then fetch the
// updated row to return a Model. This reduces the chance of clobbering
// other fields and makes the operation observable to callers.
let _res = Entity::update_many()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只是一个model更新用得着update many吗,update many本身性能很差的

Copy link
Member

@Reverier-Xu Reverier-Xu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 不要自己写json序列化与反序列化,使用seaorm types
  2. 使用正确的数据库操作函数

@Xiaozonglin
Copy link
Member Author

需要在reports数据表中添加likes列(text),将以数组的形式存储点赞的用户

likes列的数据类型改为json,默认值为[]。

@Reverier-Xu
Copy link
Member

Reverier-Xu commented Nov 13, 2025 via email

use sea_orm::{
entity::prelude::*, ActiveValue, FromQueryResult, IntoActiveModel, JoinType, QuerySelect,
};
use sea_orm::JsonValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是这么用的啊,参考 https://www.sea-ql.org/SeaORM/docs/generate-entity/column-types 直接使用结构体定义一个数组结构

pub content: Option<String>,
// Use SeaORM's JsonValue for JSON column storage
#[sea_orm(column_type = "Json", nullable)]
pub likes: Option<JsonValue>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的效果应该是

pub likes: Likes

...

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, FromJsonQueryResult, ...)]
struct Likes(Vec<i64>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants