mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Initial Typescript models.
This commit is contained in:
parent
04e9f06e93
commit
0aaba8cbd1
74 changed files with 1144 additions and 768 deletions
32
queries/admin/website/createWebsite.ts
Normal file
32
queries/admin/website/createWebsite.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { Website } from '@prisma/client';
|
||||
import cache from 'lib/cache';
|
||||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function createWebsite(
|
||||
userId: string,
|
||||
data: {
|
||||
id: string;
|
||||
name: string;
|
||||
domain: string;
|
||||
shareId?: string;
|
||||
},
|
||||
): Promise<Website> {
|
||||
return prisma.client.website
|
||||
.create({
|
||||
data: {
|
||||
user: {
|
||||
connect: {
|
||||
id: userId,
|
||||
},
|
||||
},
|
||||
...data,
|
||||
},
|
||||
})
|
||||
.then(async data => {
|
||||
if (cache.enabled) {
|
||||
await cache.storeWebsite(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue