moleculer-db icon indicating copy to clipboard operation
moleculer-db copied to clipboard

issue with #235

Open 0x0a0d opened this issue 2 years ago • 4 comments

with default validator option strict "remove" , update params will be remove everything except id

0x0a0d avatar Jan 04 '23 03:01 0x0a0d

pull #235

0x0a0d avatar Jan 04 '23 03:01 0x0a0d

What's your suggestion?

icebob avatar Jan 12 '23 18:01 icebob

 		update: {
 			rest: "PUT /:id",
 			params: {
-				id: { type: "any" }
+				$$root: true,
+				type: 'object',
+				strict: false,
+				props: {
+					id: { type: "any" }
+				}
 			},
 			handler(ctx) {

Because I'm using default (fastest-validator), so I created this patch to fix problem, but I'm not sure with other validators. In general, I think this pull should be reverted

0x0a0d avatar Jan 14 '23 17:01 0x0a0d

This suggestion works for you only, it's not a common solution. By the way, I think for your case, $$strict: false can be enough.

icebob avatar Jan 16 '23 19:01 icebob