Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## major.minor.patch (yyyy.mm.dd)

## 2.0.0 (2025.06.01)

### Changed

* Passing `conn` as part of `opts` when calling a function, as this reduces code duplication. [PR #82](https://github.com/jaeyson/ex_typesense/pull/82)

### Chore

* Bumped dev dependencies

## 1.2.1 (2025.05.11)

### Fixed
Expand Down
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,24 @@
> Under the hood, this library utilizes [open_api_typesense](https://github.com/jaeyson/open_api_typesense)
> to make sure it adheres to [Typesense's OpenAPI spec](https://github.com/typesense/typesense-api-spec).

> #### upgrading to `1.0.0` contains **LOTS** of breaking changes. {: .warning}
> #### Upgrading to v2 {: .warning}
>
> Purpose of v2 is to reduce code duplication (from v1) and to streamline
> passing of options (including `conn`). The breaking change here
> is that `conn` is now part of `opts`. > when calling functions, see
> example below:

```elixir
# pre-v2
ExTypesense.list_collections(conn, opts)

# v2
ExTypesense.list_collections(conn: conn)

# another way (v2)
opts = [limit: 1, conn: conn]
ExTypesense.list_collections(opts)
```

## Installation

Expand All @@ -100,7 +117,7 @@ Add `:ex_typesense` to your list of dependencies in the Elixir project config fi
def deps do
[
# From default Hex package manager
{:ex_typesense, "~> 1.2"}
{:ex_typesense, "~> 2.0"}

# Or from GitHub repository, if you want the latest greatest from main branch
{:ex_typesense, git: "https://github.com/jaeyson/ex_typesense.git"}
Expand Down Expand Up @@ -166,6 +183,12 @@ config :open_api_typesense,
scheme: "https"
```

Test if working:

```elixir
ExTypesense.health()
```

### using map

Option 2: Set credentials from a map
Expand Down Expand Up @@ -201,7 +224,7 @@ conn = %{

# NOTE: create a collection and import documents
# first before using the command below
ExTypesense.search(conn, collection_name, query)
ExTypesense.search(collection_name, query, conn: conn)
```

Or convert your struct to map, as long as the keys matches in [`OpenApiTypesense.Connection.t()`](https://hexdocs.pm/open_api_typesense/OpenApiTypesense.Connection.html#t:t/0):
Expand All @@ -211,7 +234,7 @@ conn = Map.from_struct(MyApp.Credential)

# NOTE: create a collection and import documents
# first before using the command below
ExTypesense.search(conn, collection_name, query)
ExTypesense.search(collection_name, query, conn: conn)
```

Or you don't want to change the fields in your Ecto schema, thus you convert it to map:
Expand All @@ -233,7 +256,7 @@ conn =

# NOTE: create a collection and import documents
# first before using the command below
ExTypesense.search(conn, collection_name, query)
ExTypesense.search(collection_name, query, conn: conn)
```

Or just plain map
Expand All @@ -246,7 +269,7 @@ conn = %{
scheme: "http"
}

ExTypesense.health(conn)
ExTypesense.health(conn: conn)
```

<!-- tabs-close -->
Expand Down
195 changes: 62 additions & 133 deletions lib/ex_typesense.ex

Large diffs are not rendered by default.

Loading