add timestamp column to prisma realtime queries
This commit is contained in:
@@ -13,7 +13,8 @@ export function getEvents(...args: [websiteId: string, filters: QueryFilters]) {
|
|||||||
function relationalQuery(websiteId: string, filters: QueryFilters) {
|
function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||||
const { startDate } = filters;
|
const { startDate } = filters;
|
||||||
|
|
||||||
return prisma.client.websiteEvent.findMany({
|
return prisma.client.websiteEvent
|
||||||
|
.findMany({
|
||||||
where: {
|
where: {
|
||||||
websiteId,
|
websiteId,
|
||||||
createdAt: {
|
createdAt: {
|
||||||
@@ -23,6 +24,14 @@ function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'desc',
|
createdAt: 'desc',
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
.then(a => {
|
||||||
|
return Object.values(a).map(a => {
|
||||||
|
return {
|
||||||
|
...a,
|
||||||
|
timestamp: new Date(a.createdAt).getTime() / 1000,
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ export async function getSessions(...args: [websiteId: string, filters: QueryFil
|
|||||||
async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||||
const { startDate } = filters;
|
const { startDate } = filters;
|
||||||
|
|
||||||
return prisma.client.session.findMany({
|
return prisma.client.session
|
||||||
|
.findMany({
|
||||||
where: {
|
where: {
|
||||||
websiteId,
|
websiteId,
|
||||||
createdAt: {
|
createdAt: {
|
||||||
@@ -23,6 +24,14 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'desc',
|
createdAt: 'desc',
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
.then(a => {
|
||||||
|
return Object.values(a).map(a => {
|
||||||
|
return {
|
||||||
|
...a,
|
||||||
|
timestamp: new Date(a.createdAt).getTime() / 1000,
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user