add: store is_like on reactions

This commit is contained in:
trisua 2025-03-24 22:49:15 -04:00
parent 382e3bc7a6
commit 0ea6b25138
5 changed files with 15 additions and 4 deletions

View file

@ -3,5 +3,6 @@ CREATE TABLE IF NOT EXISTS reactions (
created INTEGER NOT NULL,
owner INTEGER NOT NULL,
asset INTEGER NOT NULL,
asset_type TEXT NOT NULL
asset_type TEXT NOT NULL,
is_like INTEGER NOT NULL
)

View file

@ -22,6 +22,7 @@ impl DataManager {
owner: get!(x->2(u64)) as usize,
asset: get!(x->3(u64)) as usize,
asset_type: serde_json::from_str(&get!(x->4(String))).unwrap(),
is_like: if get!(x->5(u8)) == 1 { true } else { false },
}
}
@ -64,13 +65,14 @@ impl DataManager {
let res = execute!(
&conn,
"INSERT INTO reactions VALUES ($1, $2, $3, $4, $5",
"INSERT INTO reactions VALUES ($1, $2, $3, $4, $5, $6)",
&[
&data.id.to_string().as_str(),
&data.created.to_string().as_str(),
&data.owner.to_string().as_str(),
&data.asset.to_string().as_str(),
&serde_json::to_string(&data.asset_type).unwrap().as_str(),
&(if data.is_like { 1 } else { 0 }).to_string().as_str()
]
);