{"id":22790307,"url":"https://github.com/zven21/turbo_ecto","last_synced_at":"2025-08-10T04:36:36.163Z","repository":{"id":47687392,"uuid":"143138007","full_name":"zven21/turbo_ecto","owner":"zven21","description":"A rich ecto component, including search sort and paginate.","archived":false,"fork":false,"pushed_at":"2021-08-18T03:40:45.000Z","size":490,"stargazers_count":65,"open_issues_count":10,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-16T01:41:57.857Z","etag":null,"topics":["ecto","elixir","paginate","ransack","searching","sort"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/turbo_ecto","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zven21.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-01T10:00:15.000Z","updated_at":"2025-04-29T13:16:35.000Z","dependencies_parsed_at":"2022-08-23T14:50:19.987Z","dependency_job_id":null,"html_url":"https://github.com/zven21/turbo_ecto","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zven21/turbo_ecto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zven21%2Fturbo_ecto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zven21%2Fturbo_ecto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zven21%2Fturbo_ecto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zven21%2Fturbo_ecto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zven21","download_url":"https://codeload.github.com/zven21/turbo_ecto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zven21%2Fturbo_ecto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269677473,"owners_count":24457853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecto","elixir","paginate","ransack","searching","sort"],"created_at":"2024-12-12T02:19:57.946Z","updated_at":"2025-08-10T04:36:36.134Z","avatar_url":"https://github.com/zven21.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Turbo Ecto\n\n[![Build Status](https://travis-ci.org/zven21/turbo_ecto.svg?branch=master)](https://travis-ci.org/zven21/turbo_ecto)\n[![Coverage Status](https://coveralls.io/repos/github/zven21/turbo_ecto/badge.svg)](https://coveralls.io/github/zven21/turbo_ecto)\n[![Module Version](https://img.shields.io/hexpm/v/turbo_ecto.svg)](https://hex.pm/packages/turbo_ecto)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/turbo_ecto/)\n[![Total Download](https://img.shields.io/hexpm/dt/turbo_ecto.svg)](https://hex.pm/packages/turbo_ecto)\n[![License](https://img.shields.io/hexpm/l/turbo_ecto.svg)](https://github.com/zven21/turbo_ecto/blob/master/LICENSE.md)\n[![Last Updated](https://img.shields.io/github/last-commit/zven21/turbo_ecto.svg)](https://github.com/zven21/turbo_ecto/commits/master)\n\n\nTurbo is a very rich ecto component,including search sort and paginate. Inspiration by ruby [ransack](https://github.com/activerecord-hackery/ransack) and learn from [rummage_ecto](https://github.com/aditya7iyengar/rummage_ecto)\n\nPhoenix support `turbo_html`, check [this](https://github.com/zven21/turbo_html) repos.\n\n## Table of contents\n\n* [Getting started](#getting-started)\n* [Examples](#examples)\n* [Search Matchers](#search-matchers)\n* [Features](#features)\n* [Contributing](#contributing)\n* [Make a pull request](#make-a-pull-request)\n* [License](#license)\n* [Credits](#credits)\n\n## Getting started\n\nThe package can be installed by adding `:turbo_ecto` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:turbo_ecto, \"~\u003e 1.0.1\"}\n  ]\nend\n```\n\nAdd the Repo of your app and the desired per_page to the `:turbo_ecto` configuration in `config.exs`:\n\n```elixir\nconfig :turbo_ecto, Turbo.Ecto,\n  repo: MyApp.Repo,\n  per_page: 10\n```\n\nYou can also define other configurations with `entry_name` and `pagenate_name` in `config.exs`.\n\n## Examples\n\nCategory Table Structure:\n\nField         | Type          | Comment\n------------- | ------------- | ---------\n`name`        | string        |\n\nPost Table Structure:\n\n Field        | Type          | Comment\n------------- | ------------- | ---------\n`name`        | string        |\n`body`        | text          |\n`price`       | float         |\n`category_id` | integer       |\n`available`   | boolean       |\n\n```elixir\niex\u003e params = %{\n      \"q\" =\u003e %{\"name_and_category_name_like\" =\u003e \"elixir\"},\n      \"s\" =\u003e \"inserted_at+asc\",\n      \"page\" = 0,\n      \"per_page\" =\u003e 20\n     }\n\niex\u003e Turbo.Ecto.turbo(Turbo.Ecto.Schemas.Post, params)\n%{\n  datas: [%Turbo.Ecto.Schemas.Post{}],\n  paginate: %{\n    current_page: 10,\n    next_page: 11,\n    per_page: 20,\n    prev_page: 9,\n    total_count: 100,\n    total_pages: 20\n  }\n}\n```\n\n### The 2 more commonly used API are as follows：\n\n#### `Turbo.Ecto.turbo(queryable, params, opts \\\\ [])`\n\n* 1 queryable: receives a schema object or an Ecto.Query.t() object\n\n* 2 params: supports 4 parameters.\n  - `q` or `filter` to receive pattern matching information, e.g. ```params = %{\"q\" ⇒ %{\"name_like\" ⇒ \"elixir\"}}``` or ```params = %{\"filter\" ⇒ %{\"name_like\" ⇒ \"elixir\"}```\n  - `s` or `sort` Receive sort information. e.g. ```params = %{\"sort\" ⇒ \"position+asc\"}``` or ```params = %{\"s\" ⇒ \"inserted_at+desc\"}```\n  - `page` Receive query page number. e.g. ```params = %{\"page\" ⇒ 1}```\n  - `per_page` Receive the number of pages. e.g. ```params = %{\"per_page\" ⇒ 20}```\n\n* 3 opts: currently receives the following information:\n  - `paginate_name`: sets the pagination key value of the returned result\n  - `entry_name`: sets the key value of the returned result object\n  - `prefix`: table prefix\n  - `with_paginate`: whether to include pagination information, default `true`\n  - `callback`: callback processing for `queryable`\n\n#### `Turbo.Ecto.turboq(queryable, params, opts)`\n\nReturns an Ecto.Query.t() object\n\nMore example pls move: [docs](https://hexdocs.pm/turbo_ecto/api-reference.html)\n\n## Search Matchers\n\nList of all possible `search_types`:\n\nPredicate         | Description               | Note\n----------------- | -----------------------   | ----\n`*_eq`            | equal                     | SQL: `col = 'value'`\n`*_not_eq`        | not equal                 | SQL: `col != 'value'`\n`*_lt`            | less than                 | SQL: `col \u003c 1024`\n`*_lteq`          | less than or equal        | SQL: `col \u003c= 1024`\n`*_gt`            | greater than              | SQL: `col \u003e 1024`\n`*_gteq`          | greater than or equal     | SQL: `col \u003e= 1024`\n`*_is_present`    | not null and not empty    | Only compatible with string columns. e.g.: `q[name_present  ]=1` SQL: `col is not null AND col != ''`\n`*_is_null`       | is null true or false     | SQL: `col is null` or `col is not null`\n`*_like`          | contains value            | SQL: `col LIKE '%value%'`\n`*_ilike`         | contains any of           | SQL: `col ILIKE '%value%'`\n`*_is_true`       | is true or false          | SQL: `col is true or col is false`\n`*_is_not_true`   | is true or false          | SQL: `col is not true or col is false`\n`*_is_false`      | is true or false          | SQL: `col is false`\n`*_is_not_false`  | is true or false          | SQL: `col is not false`\n`*_is_null`       | is null                   | SQL: `col is nil`\n`*_is_not_null`   | is not null               | SQL: `col is not nil`\n`*_in`            | match any values in array | e.g.: `q[name_in][]=Alice\u0026q[name_in][]=Bob` SQL: `name in ('Alice', 'Bob')`\n`*_not_in`        | not contains              | SQL: `col not in ('Alice', 'Bob')`\n`*_start_with`    | start with values         | SQL: `col LIKE '%value'`\n`*_not_start_with`| not start with values     | SQL: `col not LIKE '%value'`\n`*_end_with`      | end with values           | SQL: `col LIKE 'value%'`\n`*_not_end_with`  | not end with values       | e.g.: `q[name_not_end_with][]=Alice` SQL: `col not LIKE 'value%'  `\n`*_between`       | begin \u003c between \u003c end     | e.g.: `q[price_between][]=100\u0026q[price_between][]=200` SQL: `100 \u003c=   price and price \u003c= 200`)\n\n## Contributing\n\nBug report or pull request are welcome.\n\n### Make a pull request\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\nPlease write unit test with your code if necessary.\n\n## Copyright and License\n\nCopyright (c) 2018 Zven Wang\n\nThe library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n\n## Credits\n\n* [ecto](https://github.com/elixir-ecto/ecto) - Very great API.\n* [ransack](https://github.com/activerecord-hackery/ransack) - Initial inspiration of this project.\n* [rummage_ecto](https://github.com/aditya7iyengar/rummage_ecto) - Similar implementation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzven21%2Fturbo_ecto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzven21%2Fturbo_ecto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzven21%2Fturbo_ecto/lists"}