sommeeeR
sommeeeR
Explore posts from servers
PPrisma
Created by sommeeeR on 10/19/2024 in #help-and-questions
Lambda Layer
No description
4 replies
PPrisma
Created by sommeeeR on 4/26/2024 in #help-and-questions
anyway i can have the _sum in this findMany()
Anyway I can have the _sum in findMany() or should i use typescript to get the sum?
const bookings = await db.booking.findMany({
select: {
courseId: true,
totalPersons: true
},
});

const sum = await db.booking.aggregate({
_sum: {
totalPersons: true,
},
});
const bookings = await db.booking.findMany({
select: {
courseId: true,
totalPersons: true
},
});

const sum = await db.booking.aggregate({
_sum: {
totalPersons: true,
},
});
2 replies
PPrisma
Created by sommeeeR on 4/12/2024 in #help-and-questions
Returning the next day closest to NOW
So I have a list of dates, and im trying to return the next date that is closest to new Date.now(); Here is the code:
const course = await db.course.findFirst({
where: {
id: params.id,
},
include: {
courseDate: {
where: {
from: {
gte: new Date(),
},
},
take: 1,
},
},
});
const course = await db.course.findFirst({
where: {
id: params.id,
},
include: {
courseDate: {
where: {
from: {
gte: new Date(),
},
},
take: 1,
},
},
});
This doesnt work it returns :
[
{
id: 10,
from: 2024-04-13T10:00:00.000Z,
to: 2024-04-13T14:00:00.000Z,
courseId: 8
}
]
[
{
id: 10,
from: 2024-04-13T10:00:00.000Z,
to: 2024-04-13T14:00:00.000Z,
courseId: 8
}
]
This is my entire courseDate array: https://bpa.st/NK6Q - as you can see there the closest date from now(2024-04-12T06:04:45.733Z) should be the courseDate with id: 21. Anyone know what it might be ? 🙂
2 replies
PPrisma
Created by sommeeeR on 4/11/2024 in #help-and-questions
Get the next date with prisma
const course = await db.course.findFirst({
where: {
slug: params.slug,
},
include: {
courseDate: { // i want the next one from NOW
orderBy: {
from: 'asc',
}
},
},
});
const course = await db.course.findFirst({
where: {
slug: params.slug,
},
include: {
courseDate: { // i want the next one from NOW
orderBy: {
from: 'asc',
}
},
},
});
guys i want to get next courseDate from today and only that one. how can i do that using this query? 🙂
10 replies