Packages
ex_aliyun_ots
0.6.3
0.15.3
0.15.2
0.15.1
0.15.0
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.13.1
0.13.0
0.12.4
0.12.3
0.12.2
0.12.1
0.12.0
0.11.1
0.11.0
0.10.0
0.9.0
0.8.0
0.7.1
0.7.0
0.6.10
0.6.9
0.6.8
0.6.7
0.6.6
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.9
0.5.8
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.2
0.2.1
0.2.0
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Aliyun TableStore SDK for Elixir/Erlang
Current section
Files
Jump to
Current section
Files
ex_aliyun_ots
README.md
README.md
# ExAliyunOts
[](https://hex.pm/packages/ex_aliyun_ots)
[](https://coveralls.io/github/xinz/ex_aliyun_ots?branch=master)
Aliyun TableStore SDK for Elixir/Erlang
> TableStore is a NoSQL database service built on Alibaba Cloud’s Apsara distributed operating system that can store and access large volumes of structured data in real time.
## Installation
```elixir
def deps do
[
{:ex_aliyun_ots, "~> 0.6"}
]
end
```
## Configuration
```elixir
config :ex_aliyun_ots, :my_instance
name: "MyInstanceName",
endpoint: "MyInstanceEndpoint",
access_key_id: "MyAliyunRAMKeyID",
access_key_secret: "MyAliyunRAMKeySecret"
config :ex_aliyun_ots,
instances: [:my_instance],
debug: false,
enable_tunnel: false
```
* `debug`, optional, specifies whether to enable debug logger, by default it is false, and please DO NOT use debug mode in production.
* `enable_tunnel`, optional, specifies whether to enable tunnel functions, there will startup tunnel related supervisor and registry when enable it, by default it is false.
## Using ExAliyunOts
To use `ExAliyunOts`, a module that calls `use ExAliyunOts` has to be defined:
```elixir
defmodule MyApp.TableStore do
use ExAliyunOts, instance: :my_instance
end
```
This automatically defines some macros and functions in the `MyApp.TableStore` module, here are some examples:
```elixir
import MyApp.TableStore
# Create table
create_table "table",
[{"pk1", :integer}, {"pk2", :string}]
# Put row
put_row "table",
[{"pk1", "id1"}],
[{"attr1", 10}, {"attr2", "attr2_value"}],
condition: condition(:expect_not_exist),
return_type: :pk
# Search index
search "table", "index_name",
search_query: [
query: match_query("age", 28),
sort: [
field_sort("age", order: :desc)
]
]
# Local transaction
start_local_transaction "table", {"partition_key", "partition_value"}
```
## ExAliyunOts API
There are two ways to use ExAliyunOts:
* using macros and functions from your own ExAliyunOts module, like `MyApp.TableStore`.
* using macros and functions from the `ExAliyunOts` module.
All defined functions and macros in `ExAliyunOts` are available and referrible for your own ExAliyunOts module as well, except that the given arity of functions may different, because the `instance` parameter of each invoke request is NOT needed from your own ExAliyunOts module although the `ExAliyunOts` module defines it.
## Ecto Adapter
Here is a [Tablestore adapter for Ecto](https://hex.pm/packages/ecto_tablestore) implementation as an alternative.
## Supported Functions
* Table Operations
* Row Operations
* Conditional update
* Auto-increment function of the primary key column
* Filter
* Atomic counters
* Search index
* Local transation
* Tunnel service
* Timeline mode
## Supported API
* Table
* CreateTable
* ListTable
* DeleteTable
* UpdateTable
* DescribeTable
* Row
* PutRow
* GetRow
* UpdateRow
* DeleteRow
* GetRange
* BatchGetRow
* BatchWriteRow
* SearchIndex
* CreateSearchIndex
* DescribeSearchIndex
* DeleteSearchIndex
* Search
* LocalTransaction
* StartLocalTransaction
* CommitTransaction
* AbortTransaction
* SDK built-in
* IterateAllRange
* Sequence
* Tunnel service
* Timeline mode
## Thanks
Thanks very much for the help and support of the Alibaba TableStore offical support team.
## References
Alibaba Tablestore product official references:
* [English document](https://www.alibabacloud.com/help/doc-detail/27280.htm)
* [中文文档](https://help.aliyun.com/document_detail/27280.html)
## License
MIT