elixir-ecto/ecto là dự án mã nguồn mở trên GitHub với 6.5k sao, viết chủ yếu bằng Elixir. A toolkit for data mapping and language integrated query.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Ecto is a toolkit for data mapping and language integrated query for Elixir. Here is an example:
# In your config/config.exs file
config :my_app, ecto_repos: [Sample.Repo]
config :my_app, Sample.Repo,
database: "ecto_simple",
username: "postgres",
password: "postgres",
hostname: "localhost",
port: "5432"
# In your application code
defmodule Sample.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres
end
defmodule Sample.Weather do
use Ecto.Schema
schema "weather" do
field :city # Defaults to type :string
field :temp_lo, :integer
field :temp_hi, :integer
field :prcp, :float, default: 0.0
end
end
defmodule Sample.App do
import Ecto.Query
alias Sample.{Weather, Repo}
def keyword_query do
query =
from w in Weather,
where: w.prcp > 0 or is_nil(w.prcp),
select: w
Repo.all(query)
end
def pipe_query do
Weather
|> where(city: "Kraków")
|> order_by(:temp_lo)
|> limit(10)
|> Repo.all
end
end
Ecto is commonly used to interact with databases, such as PostgreSQL and MySQL via Ecto.Adapters.SQL (source code). Ecto is also commonly used to map data from any source into Elixir structs, whether they are backed by a database or not.
See the getting started guide and the online documentation for more information. Other resources available are:
Programming Ecto, by Darin Wilson and Eric Meadows-Jönsson, which guides you from fundamentals up to advanced concepts
The Little Ecto Cookbook, a free ebook by Dashbit, which is a curation of the existing Ecto guides with some extra contents
Usage
You need to add both Ecto and the database adapter as a dependency to your mix.exs file. The supported databases and their adapters are:
Database
Ecto Adapter
Dependencies
PostgreSQL
Ecto.Adapters.Postgres
ecto_sql + postgrex
MySQL
Ecto.Adapters.MyXQL
ecto_sql + myxql
MSSQL
Ecto.Adapters.Tds
ecto_sql + tds
SQLite3
Ecto.Adapters.SQLite3
ecto_sqlite3
ClickHouse
Ecto.Adapters.ClickHouse
ecto_ch
ETS
Etso
etso
For example, if you want to use PostgreSQL, add to your mix.exs file:
defp deps do
[
{:ecto_sql, "~> 3.0"},
{:postgrex, ">= 0.0.0"}
]
end
Then run mix deps.get in your shell to fetch the dependencies. If you want to use another database, just choose the proper dependency from the table above.
Finally, in the repository definition, you will need to specify the adapter: respective to the chosen dependency. For PostgreSQL it is:
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres,
...
IPv6 support
If your database's host resolves to ipv6 address you should
add socket_options: [:inet6] to configuration block like below:
With version 3.0, Ecto API has become stable. Our main focus is on providing
bug fixes and incremental changes.
Important links
Documentation
Mailing list
Examples
Running tests
Clone the repo and fetch its dependencies:
$ git clone https://github.com/elixir-ecto/ecto.git
$ cd ecto
$ mix deps.get
$ mix test
Note that mix test does not run the tests in the integration_test folder. To run integration tests, you can clone ecto_sql in a sibling directory and then run its integration tests with the ECTO_PATH environment variable pointing to your Ecto checkout:
$ cd ..
$ git clone https://github.com/elixir-ecto/ecto_sql.git
$ cd ecto_sql
$ mix deps.get
$ ECTO_PATH=../ecto mix test.all
Running containerized tests
It is also possible to run the integration tests under a containerized environment using earthly:
$ earthly -P +all
You can also use this to interactively debug any failing integration tests using:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/elixir-ecto/ecto là nguồn chính thức.
elixir-ecto/ecto có bao nhiêu sao?
elixir-ecto/ecto có 6.5k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/elixir-ecto/ecto. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
elixir-ecto/ecto có phải mã nguồn mở không?
Có — elixir-ecto/ecto phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/elixir-ecto/ecto.
elixir-ecto/ecto còn đang phát triển không?
Commit gần nhất trên elixir-ecto/ecto là 3 ngày trước (theo timestamp GitHub). Repo có 1.5k fork — một chỉ báo về mức độ quan tâm của cộng đồng.
elixir-ecto/ecto dùng license gì?
elixir-ecto/ecto phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
elixir-ecto/ecto là gì?
elixir-ecto/ecto (elixir-ecto/ecto) là dự án Elixir trên GitHub. Theo mô tả gốc: A toolkit for data mapping and language integrated query.
elixir-ecto/ecto viết bằng ngôn ngữ gì?
elixir-ecto/ecto chủ yếu viết bằng Elixir. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về ecto?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về ecto.