Is there a way to override the "id" as a default filter in findOne/deleteOne/updateOne endpoint? #1506
Replies: 4 comments 2 replies
-
@jhonnydelima - What database are you using? You could theoretically replace the id (its value) with the code you are getting for the establishments and for just that entity, If you can do that, I believe the "one" methods will still work. Scott |
Beta Was this translation helpful? Give feedback.
-
So you are using TypeORM or Sequelize? At any rate, what I mean is, in your entity, you could define the @entity()
} Since the What is the establishment id anyway? Scott |
Beta Was this translation helpful? Give feedback.
-
TypeORM. Id is the primary key and code is the registered number of a company (establishment). The thing is, I just started the project for some tests and I haven't created any service or resolver yet, I'm using only the default methods (autogenerated) for now. My establishments module only contains the DTOs, the entity, and the module (posted in the previous comment).
But based on what you said I believe it's not possible to just override the method, maybe I need to create a new query for that. As I said, I don't want the method to only accept the value of code, but also to change the name of the filter. Jhonny |
Beta Was this translation helpful? Give feedback.
-
@jhonnydelima I'd probably do something like this Your query could look like
I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I need to create a graphql query that searches for establishments based on their code. With that said, I was thinking about using the query "findOne" which is automatically generated, however, it uses the "id" as the default filter. Is it possible to override this filter with the code (in my case)?
Beta Was this translation helpful? Give feedback.
All reactions