2024-12-30 08:26:40 +08:00
|
|
|
import { api } from "../trpc";
|
|
|
|
|
|
|
|
export function usePost() {
|
|
|
|
const utils = api.useUtils();
|
2025-01-22 18:56:27 +08:00
|
|
|
const create: any = api.post.create.useMutation({
|
2024-12-30 08:26:40 +08:00
|
|
|
onSuccess: () => {
|
|
|
|
utils.post.invalidate();
|
|
|
|
},
|
|
|
|
});
|
2025-01-22 18:56:27 +08:00
|
|
|
const update: any = api.post.update.useMutation({
|
2024-12-30 08:26:40 +08:00
|
|
|
onSuccess: () => {
|
|
|
|
utils.post.invalidate();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const deleteMany = api.post.deleteMany.useMutation({
|
|
|
|
onSuccess: () => {
|
|
|
|
utils.post.invalidate();
|
|
|
|
},
|
|
|
|
});
|
2025-01-22 18:56:27 +08:00
|
|
|
const softDeleteByIds: any = api.post.softDeleteByIds.useMutation({
|
2024-12-30 08:26:40 +08:00
|
|
|
onSuccess: () => {
|
|
|
|
utils.post.invalidate();
|
|
|
|
},
|
|
|
|
});
|
2025-01-22 18:56:27 +08:00
|
|
|
const restoreByIds: any = api.post.restoreByIds.useMutation({
|
2024-12-30 08:26:40 +08:00
|
|
|
onSuccess: () => {
|
|
|
|
utils.post.invalidate();
|
|
|
|
},
|
2025-01-22 18:56:27 +08:00
|
|
|
});
|
2024-12-30 08:26:40 +08:00
|
|
|
return {
|
|
|
|
create,
|
|
|
|
update,
|
|
|
|
deleteMany,
|
|
|
|
softDeleteByIds,
|
2025-01-22 18:56:27 +08:00
|
|
|
restoreByIds,
|
2024-12-30 08:26:40 +08:00
|
|
|
};
|
|
|
|
}
|