Adocasts Plus Timed Exclusive

Please check back in 2 days. Get immediate access to this lesson and more by joining Adocasts Plus for $8.00/mo or signing into your existing Adocasts Plus account.

robot mascot smiling

Model Query Builder Macros in AdonisJS 6

In this lesson, we'll learn how we can add custom methods to the Model Query Builder with Lucid in AdonisJS 6 using macros.

Published
Dec 10
Duration
7m 44s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Chapters

00:00 - Setting the Baseline
01:01 - Where Do We Define our Macros?
01:47 - Defining A GetCount Model Query Builder Macro
03:15 - Defining our Macro Types on the Model Query Builder
05:54 - Passing Arguments into Macros

What is a Model Query Builder Macro?

In AdonisJS, macros provide us a way to easily extend internal AdonisJS classes with our own methods. A lot in AdonisJS is macroable, including the request, response, and query builder.

When we add a macro, that function will then be readily available to use with instances of whatever class it is we've defined that macro. In the case of the Model Query Builder, adding a macro will make that function available within all model's query builders.

Adocasts Plus Timed Exclusive

Please check back in 2 days. Get immediate access to this lesson and more by joining Adocasts Plus for $8.00/mo or signing into your existing Adocasts Plus account.

Join The Discussion! (0 Comments)

Please sign in or sign up for free to join in on the dicussion.

robot comment bubble

Be the first to Comment!