# Query Extensions

Query extensions are methods added to [standard WireBootstrap select queries](https://docs.wirebootstrap.com/wirebootstrap/creating-queries/select-queries) that are specific to a [data connector](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors).  &#x20;

## Creating an Extension

To create an extension, override the base `wire.data.select` function and then add methods to the new version.

<pre class="language-javascript"><code class="lang-javascript"><strong>wire.data.select = function () {
</strong>
    let self = select.apply(null, arguments);        
    
    self.myMethod = function(){
        ///
    }
}
</code></pre>

## Methods

Query extensions can be used for a variety of operations specific to a data connector. &#x20;

Here, a method is used to wrap a `category` filter on a specific `value`.

```javascript
wire.data.select = function () {
    ...
    self.category = function(value){              
        return self.eq("category", value);
    }
}
```

This new method can now be used to create a standard query.

```javascript
const query = wire.data.select().from("product").category("apples");
```

## Custom Property

Query extensions can also be used to pass custom data to a data connector.  Use the `Custom` property on the [TableQuery](https://docs.wirebootstrap.com/wirebootstrap/reference/wire.data/wire.data.tablequery) class inside the extension method to pass custom data to a data connector.

The following example is a short/modified version of a method taken from the [WireBootstrap for Azure](https://docs.wirebootstrap.com/azure/query-extensions) search query extension.

```javascript
wire.data.select = function () {
    ...
    self.facet = function(field){              

        self.Custom = self.Custom || {};

        self.Custom.facets = self.Custom.facets || [];

        self.Custom.facets.push(field);
        
        return this;

    }    
}
```
