mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
more users stuff
This commit is contained in:
35
src/actions/userActions.ts
Normal file
35
src/actions/userActions.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
"use server";
|
||||
import { eq, not , asc} from "drizzle-orm";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { db } from "@db/index";
|
||||
import { usersMerged } from "@schemas/schema";
|
||||
|
||||
export const getData = async () => {
|
||||
const data = await db.select().from(usersMerged).orderBy(asc(usersMerged.email));
|
||||
return data;
|
||||
};
|
||||
|
||||
export const addUser = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
|
||||
await db.insert(usersMerged).values({
|
||||
first_name : first_name, last_name: last_name, username: username, email: email, password_hash : password_hash
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteUser = async (id: string) => {
|
||||
await db.delete(usersMerged).where(eq(usersMerged.id, id));
|
||||
revalidatePath("/");
|
||||
};
|
||||
|
||||
export const editUser = async (id: string, first_name: string, last_name: string, username: string, email : string, password_hash: string) => {
|
||||
await db
|
||||
.update(usersMerged)
|
||||
.set({
|
||||
first_name : first_name,
|
||||
last_name: last_name,
|
||||
username: username,
|
||||
email: email,
|
||||
password_hash: password_hash
|
||||
})
|
||||
.where(eq(usersMerged.id, id));
|
||||
revalidatePath("/");
|
||||
};
|
||||
Reference in New Issue
Block a user