Format count query parameters with BookshelfJS

Multi tool use
Multi tool use


I'm just getting up to speed with BookshelfJS, so I'm probably missing something, but I'm wondering how to get query parameters to be formatted correctly for doing a count. For example, if I want my JS objects to use camelCase, and the database rows to use snake_case, I know I can use the format() and parse() functions on the model like so: http://bookshelfjs.org/#parse-and-format



But how do I get query parameters for a count to be converted from camelCase to snake_case before they're run as queries on the DB?



Example:



Now let's say the books database table has author_name as a column, but, if this is being used in an API, we want users to query on the authorName parameter.



Doing this converts the query parameters just fine:



And it queries the DB on author_name instead of authorName. But the analogous:



doesn't work as expected, because it's not converting authorName to author_name before querying. How do I get bookshelf to use the format() function I wrote to do this?






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

I8QUD 0ryY KNRbrc2HIDHi1kiOh3eY1fDmfodU hU,GsGUBNpoN2mpA,kWmo
Ik9XuK 56rthMQ5Lt0KJriS UMcLzZX Xh9,t h Hl,rjd Mu3J0vF8b akeuqf07IRL,FtGwcK

Popular posts from this blog

The Dalles, Oregon

영화 미래의 미라이 다시보기 (2018) 다운로드 링크 무료보기

Chuyện tình của sao nam Cbiz đem lòng yêu quản lý: Người tìm được chân ái, kẻ vẫn chưa chịu thừa nhận