Satish
Satish
PPrisma
Created by Satish on 10/27/2024 in #help-and-questions
@unique and @index can't be used together
Awesome ..thank you
4 replies
PPrisma
Created by Satish on 3/26/2024 in #help-and-questions
Query based on Time
@fotoflo Do you think the logic is correct?
7 replies
PPrisma
Created by Satish on 3/26/2024 in #help-and-questions
Query based on Time
I'm editing it now.
7 replies
PPrisma
Created by Satish on 3/26/2024 in #help-and-questions
Query based on Time
Ah .. it doesn't make sense to have it!! Thank you for pointing out.
7 replies
PPrisma
Created by Satish on 3/26/2024 in #help-and-questions
Query based on Time
I hope this query works?
// Get the current date and time
const currentDate = new Date();

// Calculate the start and end dates for last month
const lastMonthStartDate = new Date(currentDate);
lastMonthStartDate.setMonth(lastMonthStartDate.getMonth() - 1);
lastMonthStartDate.setHours(currentDate.getHours(), currentDate.getMinutes() - 30, 0, 0); // Adjust for 30 minutes earlier

const lastMonthEndDate = new Date(currentDate);
lastMonthEndDate.setMonth(lastMonthEndDate.getMonth() - 1);
lastMonthEndDate.setHours(currentDate.getHours(), currentDate.getMinutes(), 0, 0);

// Fetch users who logged in between last month at this time and last month at this time - 30 minutes
const users = await prisma.user.findMany({
where: {


loggedInAt: {
gte: lastMonthStartDate,
lt: lastMonthEndDate
}


}
});

return users;
// Get the current date and time
const currentDate = new Date();

// Calculate the start and end dates for last month
const lastMonthStartDate = new Date(currentDate);
lastMonthStartDate.setMonth(lastMonthStartDate.getMonth() - 1);
lastMonthStartDate.setHours(currentDate.getHours(), currentDate.getMinutes() - 30, 0, 0); // Adjust for 30 minutes earlier

const lastMonthEndDate = new Date(currentDate);
lastMonthEndDate.setMonth(lastMonthEndDate.getMonth() - 1);
lastMonthEndDate.setHours(currentDate.getHours(), currentDate.getMinutes(), 0, 0);

// Fetch users who logged in between last month at this time and last month at this time - 30 minutes
const users = await prisma.user.findMany({
where: {


loggedInAt: {
gte: lastMonthStartDate,
lt: lastMonthEndDate
}


}
});

return users;
7 replies
PPrisma
Created by Satish on 3/26/2024 in #help-and-questions
Query based on Time
I've a cron job which runs every 30 minutes. I want to fetch all the users who last accessed the app in that period(last month) to be notified.
7 replies