lookinlab/adonis-lucid-filter

Filters with uppercase and underscores

Closed this issue · 1 comments

I have this function at my PostFilter.ts

public authorId(authorId: string): void {
   this.$query.where('authorId', authorId)
}

It does not match the value to the this function, so if I pass the { authorId: 1 } as parameter it will not call this function, and if I use another name as author_id, does not work too.

I need to convert it to authorid, then it works.

Seems that function names need to be alphanumeric without uppercase letters.

Reading the code I found the dropId property of BaseFilterModel, that by default removes _id or Id from property names.

So for my project, I just needed to add the following line to my PostFilterModel:
public static dropId = false