$crim
Explore posts from serversPPrisma
•Created by $crim on 4/30/2024 in #help-and-questions
Prisma Query
Hello I'm trying to create a search logic using nest js and prisma,
async searchConsumer(
prisma: Prisma.TransactionClient,
query: SearchAccountQuery,
page: number,
pageSize: number,
) {
try {
console.log('Rewarding Transactions Where:', {
AND: [
query.fromAmount !== undefined
? { amount: { gte: query.fromAmount } }
: {},
query.toAmount !== undefined
? { amount: { lte: query.toAmount } }
: {},
query.fromPoints !== undefined
? { points: { gte: query.fromPoints } }
: {},
query.toPoints !== undefined
? { points: { lte: query.toPoints } }
: {},
],
});
const consumers = await prisma.account.findMany({
where: {
AND: { account_type: 'consumer' },
OR: [
{ name: { contains: query.name, mode: 'insensitive' } },
{ email: { contains: query.email, mode: 'insensitive' } },
{ phone_number: { contains: query.phone_number } },
{ id: { equals: query.id } },
],
},
include: {
rewarding_transactions: {
where: {
AND: [
query.fromAmount !== undefined
? { amount: { gte: query.fromAmount } }
: {},
query.toAmount !== undefined
? { amount: { lte: query.toAmount } }
: {},
query.fromPoints !== undefined
? { points: { gte: query.fromPoints } }
: {},
query.toPoints !== undefined
? { points: { lte: query.toPoints } }
: {},
],
},
select: {
amount: true,
points: true,
},
},
},
...(page && {
...(pageSize && {
skip: Number(pageSize) * Number(page - 1),
take: Number(pageSize),
}),
}),
});
return {
totalCount: consumers.length,
data: consumers,
};
} catch (error) {
this.logger.error(error);
throw new BadRequestException(error);
}
}
But When I send a from and to amount or points I didn't get anything.4 replies
RRefine
•Created by other-emerald on 3/3/2024 in #ask-any-question
Put intial values:
I want to enter the data from the datbase |
import React from 'react';
import { IResourceComponentsProps } from '@refinedev/core';
import { Edit, useForm, useSelect } from '@refinedev/antd';
import { Form, Select } from 'antd';
export const ProductEdit: React.FC<IResourceComponentsProps> = () => {
const { formProps, saveButtonProps, queryResult } = useForm();
const productData = queryResult?.data?.data;
const { selectProps: typeSelectProps } = useSelect({
resource: 'type',
optionLabel: 'name',
optionValue: 'name',
});
const { selectProps: tierSelectProps } = useSelect({
resource: 'tier',
optionLabel: 'name',
optionValue: 'name',
});
const { selectProps: segmentSelectProps } = useSelect({
resource: 'segment',
optionLabel: 'name',
optionValue: 'name',
});
return (
<Edit saveButtonProps={saveButtonProps}>
<Form {...formProps} layout="vertical">
<Form.Item
label="Type"
name={['type', 'name']}
rules={[
{
required: false,
},
]}
>
as option value
19 replies