FilterBuilder
FilterBuilder extension works together with FilterRunnger, in most of time, it does nothing but only claims the filter name.
caution
Making custom filters by FilterBuilder and FilterRunner is suitable for advanced users, it gives you low-level access to our compiler. In most cases, you can use Functional Filter instead.
How FilterBuilder works
FilterBuilder extensions have no function to implement, the only things we need to do is claiming the name of the filter.
Example
info
You can check the demo repository for the full code.
import { FilterBuilder } from '@vulcan-sql/core';
export class PrefixFilterBuilder extends FilterBuilder {
public filterName = 'prefix';
}
Advanced: AST Visitor
FilterBuilder supports visiting and modifying the AST we parsed.Simply override the onVisit
function like below:
public override onVisit(node: nunjucks.nodes.Node) {
// you can modify nodes here
}
VulcanSQL will call this function for each node.