I want to allow to edit box name only for its owne...
# orm-help
a
I want to allow to edit box name only for its owner. I get unwanted "owner": "filed Variable '$where' expected value of type 'BoxWhereUniqueInput!' Reason: 'owner' Field 'owner' is not defined in the input type 'BoxWhereUniqueInput'"
Here is the overkill workaround:
Copy code
async updateBoxName(parent, args, context) {
			const { boxId, name } = args;
			const id = getUserId(context);
			const userBoxes = (await context.prisma.user({ id }).boxes()).map(box => box.id);
			
			if(!userBoxes.includes(boxId)) throw new Error('It is not your box.');

			return context.prisma.user({ id }).updateBox({
				where: { id: boxId },
				data: { name }
			});
		},
same problem here, I cant use owner to use "contains query":
Copy code
boxes(parent, args, context) {
			const id = getUserId(context);

			const where = args.filter ? {
				OR: [
					{ name_contains: args.filter },
					{ owner: { name_contains: args.filter } }
				]
			} : {};
			
			return context.prisma.user({ id }).boxes({ where });
		}
h
You will need to make owner unique otherwise updateBox will not work. But in your case you should use updateMany instead of single update https://www.prisma.io/docs/prisma-client/basic-data-access/writing-data-JAVASCRIPT-rsc6/#updating-and-deleting-many-records