<commit_before># querymorpher
[![Build Status](https://travis-ci.org/Kirro-io/querymorpher.svg?branch=master)](https://travis-ci.org/Kirro-io/querymorpher)
[![codecov](https://codecov.io/gh/Kirro-io/querymorpher/branch/master/graph/badge.svg)](https://codecov.io/gh/Kirro-io/querymorpher)
[![Go Report Card](https://goreportcard.com/badge/github.com/kirro-io/querymorpher)](https://goreportcard.com/report/github.com/kirro-io/querymorpher)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Simple package that converts `url.Values` to sql like query.

## Installation

```
$ go get github.com/kirro-io/querymorpher
```

## Example

```go
package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/kirro-io/querymorpher"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		q, err := querymorpher.QueryFromRequest(r)

		if err != nil {
			log.Fatal(err.Error())
		}

		fmt.Fprintf(w, q)
	})

	log.Fatal(http.ListenAndServe(":8080", nil))
}
```

```shell
$ curl "http://localhost:8080?age>=42&name=John&surname='Doe'"
age >= 42 AND name = 'John' AND surname = 'Doe'
```

## Supported operators

suffix | operator
-------|---------
__gt | >
__gte | >=
__lt | <
__lte | <=
__neq | !=

## Ordering results

For ascending ordering use `order_by=<field_name>`:

```
?age__gt=18&order_by=age
```

For descending ordering insert minus sign before field name `order_by=-<field_name>`:

```
?age__gt=18&order_by=-age
```

## Limiting results

Simply use `limit=<count>` query param.

```
?age__gt=18limit=1
```
<commit_msg>Fix typo in limit example<commit_after># querymorpher
[![Build Status](https://travis-ci.org/Kirro-io/querymorpher.svg?branch=master)](https://travis-ci.org/Kirro-io/querymorpher)
[![codecov](https://codecov.io/gh/Kirro-io/querymorpher/branch/master/graph/badge.svg)](https://codecov.io/gh/Kirro-io/querymorpher)
[![Go Report Card](https://goreportcard.com/badge/github.com/kirro-io/querymorpher)](https://goreportcard.com/report/github.com/kirro-io/querymorpher)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Simple package that converts `url.Values` to sql like query.

## Installation

```
$ go get github.com/kirro-io/querymorpher
```

## Example

```go
package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/kirro-io/querymorpher"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		q, err := querymorpher.QueryFromRequest(r)

		if err != nil {
			log.Fatal(err.Error())
		}

		fmt.Fprintf(w, q)
	})

	log.Fatal(http.ListenAndServe(":8080", nil))
}
```

```shell
$ curl "http://localhost:8080?age>=42&name=John&surname='Doe'"
age >= 42 AND name = 'John' AND surname = 'Doe'
```

## Supported operators

suffix | operator
-------|---------
__gt | >
__gte | >=
__lt | <
__lte | <=
__neq | !=

## Ordering results

For ascending ordering use `order_by=<field_name>`:

```
?age__gt=18&order_by=age
```

For descending ordering insert minus sign before field name `order_by=-<field_name>`:

```
?age__gt=18&order_by=-age
```

## Limiting results

Simply use `limit=<count>` query param.

```
?age__gt=18&limit=1
```

{'fraction_non_alphanumeric': 0.19950510361892979, 'fraction_numerical': 0.011753789050417568, 'mean_word_length': 4.585492227979275, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1133103', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1258, 'n_words': 198}