Skip to content

Commit

Permalink
v2.2.2
Browse files Browse the repository at this point in the history
v2.2.2
  • Loading branch information
davidcostadev authored Mar 2, 2021
2 parents a0502f3 + 2d9d143 commit d71bbd3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
PORT=5000
DATABASE_URL="postgresql://root:123@localhost:5432/withmoney_dev?schema=public"

DEPLOY_NAME=api.withmoney
DEPLOY_USER=username
DEPLOY_HOST=host
DEPLOY_PATH=/var/www/api.withmoney.me

SECRET_SALT=9
SECRET_KEY=onemoretime

Expand Down
17 changes: 15 additions & 2 deletions src/types/Category/queries/findMany.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { queryField, arg, nonNull, list } from '@nexus/schema';
import { NexusGenInputs } from '../../../generated/nexus';
import { getUserId } from '../../../utils';

export const CategoryFindManyQuery = queryField('findManyCategory', {
Expand All @@ -13,18 +14,30 @@ export const CategoryFindManyQuery = queryField('findManyCategory', {
resolve: async (_parent, args, ctx) => {
const userId = await getUserId(ctx);

let where: NexusGenInputs['OperationWhereInput'] | null = {};

if (args.where.name.contains) {
where = {
...args.where,
name: {
contains: args.where.name.contains,
mode: 'insensitive',
},
};
}

const data = await ctx.prisma.category.findMany({
...args,
where: {
...args.where,
...where,
userId,
},
});

const pagination = {
totalItems: await ctx.prisma.category.count({
where: {
...args.where,
...where,
userId,
},
}),
Expand Down

0 comments on commit d71bbd3

Please sign in to comment.