DevPanda
DevPanda5d ago

Multiple .meta in one route

Hey, is it possible to have multiple .meta fields in a single route or do I have to define multiple routes for that?
3 Replies
Nick
Nick5d ago
If you call .meta() multiple times the results will get merged if that's what you mean? Maybe you could share some more details?
DevPanda
DevPandaOP5d ago
here a example:
test: protectedProcedure
.meta({ permissions: ["ADMIN", "VIEW_PRODUCTS"] })
.query(async ({ ctx }) => {
return { test: "test admin" };
})
.meta({ permissions: ["TEAM", "VIEW_PRODUCTS"] })
.query(async ({ ctx }) => {
return { test: "test team" };
})
.meta({ permissions: ["CUSTOMER", "VIEW_PRODUCTS"] })
.query(async ({ ctx }) => {
return { test: "test customer" };
}),
test: protectedProcedure
.meta({ permissions: ["ADMIN", "VIEW_PRODUCTS"] })
.query(async ({ ctx }) => {
return { test: "test admin" };
})
.meta({ permissions: ["TEAM", "VIEW_PRODUCTS"] })
.query(async ({ ctx }) => {
return { test: "test team" };
})
.meta({ permissions: ["CUSTOMER", "VIEW_PRODUCTS"] })
.query(async ({ ctx }) => {
return { test: "test customer" };
}),
Nick
Nick5d ago
You can't chain anything on top of query, that creates the procedure test is the name of the procedure in this case

Did you find this page helpful?