mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Account settings page.
This commit is contained in:
parent
58a1be7a30
commit
b5cf9f8719
32 changed files with 597 additions and 162 deletions
43
lib/db.js
43
lib/db.js
|
|
@ -124,8 +124,8 @@ export async function getSession({ session_id, session_uuid }) {
|
|||
return runQuery(
|
||||
prisma.session.findOne({
|
||||
where: {
|
||||
...(session_id && { session_id }),
|
||||
...(session_uuid && { session_uuid }),
|
||||
session_id,
|
||||
session_uuid,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
|
@ -174,16 +174,53 @@ export async function saveEvent(website_id, session_id, url, event_type, event_v
|
|||
);
|
||||
}
|
||||
|
||||
export async function getAccount(username = '') {
|
||||
export async function getAccounts() {
|
||||
return runQuery(prisma.account.findMany());
|
||||
}
|
||||
|
||||
export async function getAccount({ user_id, username }) {
|
||||
return runQuery(
|
||||
prisma.account.findOne({
|
||||
where: {
|
||||
username,
|
||||
user_id,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateAccount(user_id, data) {
|
||||
return runQuery(
|
||||
prisma.account.update({
|
||||
where: {
|
||||
user_id,
|
||||
},
|
||||
data,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteAccount(user_id) {
|
||||
return runQuery(
|
||||
/* Prisma bug, does not cascade on non-nullable foreign keys
|
||||
prisma.account.delete({
|
||||
where: {
|
||||
user_id,
|
||||
},
|
||||
}),
|
||||
*/
|
||||
prisma.queryRaw(`delete from account where user_id=$1`, user_id),
|
||||
);
|
||||
}
|
||||
|
||||
export async function createAccount(data) {
|
||||
return runQuery(
|
||||
prisma.account.create({
|
||||
data,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function getPageviews(website_id, start_at, end_at) {
|
||||
return runQuery(
|
||||
prisma.pageview.findMany({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue