Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ecto, você sabe o que é ?
Search
Amanda
August 06, 2016
Technology
260
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ecto, você sabe o que é ?
Palestra apresentada no encontro do ELUG-SP
Amanda
August 06, 2016
Transcript
75 slides
Ecto Você sabe o que é?
@amandasposito @amsposito @amandasposito
None
Agenda • O que é? • Seus benefícios; • Componentes;
• Novidades da última versão.
O que é?
“Ecto is a domain specific language for writing queries and
interacting with databases in Elixir.”
object-relational mapping
object-relational mapping
None
Inspiração
LINQ Language Integrated Query
Parte do .NET Framework - Nov/2007
C#
Ecto
None
Vantagens
Composição
Você pode continuar a usar uma query em outra parte
do codigo
None
Isso é possível por causa dos Protocols de Elixir
None
Protocols ?
"Elixir provides protocols as a mechanism for polymorphism." http://elixir-lang.org/getting-started/protocols.html http://blog.plataformatec.com.br/2014/09/writing-assertive-code-with-elixir/
None
Sobre dados
Evita SQL injection
Interpolação e Casting de dados
Valores externos e expressões em Elixir podem ser adicionados a
uma query com ^ http://elixir-lang.org/getting-started/pattern-matching.html#the-pin-operator
None
None
Type safety
name == 1 ** (Ecto.Query.TypeCheckError) the following expression does not
type check:
Componentes
• Repo • Schema • Changeset • Query
Nosso modelo de dados
None
Ecto.Repo
Repo.all(query) https://hexdocs.pm/ecto/Ecto.Repo.html
Repo.start_link()
Ecto.Schema
None
None
None
Ecto.Changeset
None
None
None
Ecto.Query
None
None
https://hexdocs.pm/ecto/Ecto.Query.html#preload
https://hexdocs.pm/ecto/Ecto.Query.html#preload
https://hexdocs.pm/ecto/Ecto.Query.html#join/5
https://hexdocs.pm/ecto/Ecto.Query.html#join/5
https://hexdocs.pm/ecto/Ecto.Query.html#join/5
https://hexdocs.pm/ecto/Ecto.Query.html#preload
https://hexdocs.pm/ecto/Ecto.Query.html#preload
Novidades da última versão
Model -> Schema
Insert_all *http://blog.plataformatec.com.br/2016/05/ectos-insert_all-and-schemaless-queries/
None
Relacionamentos many_to_many
Subqueries
Chaves compostas
Otimização em connection pooling *https://github.com/elixir-ecto/ecto/releases/tag/v2.0.0 *http://blog.plataformatec.com.br/2016/04/ecto-2-0-0-rc-is-out/
Testes concorrentes, mesmo dependendo do banco de dados
Falei de mais né? Falei de mais né?
Resumindo
É uma Lib para você poder interagir com o banco
de dados
Consegue escrever queries no banco de dados escrevendo código Elixir
Composição / SQL Injection / Type Safety
Repo / Schema / Changeset / Query
https://github.com/amandasposito/ecto_demo
Obrigada!
Referências • http://blog.plataformatec.com.br/2016/05/ectos-insert_all-and-schemaless-queries/ • http://blog.plataformatec.com.br/2016/04/ecto-2-0-0-rc-is-out/ • https://hexdocs.pm/ecto/Ecto.html • https://github.com/elixir-ecto/ecto/wiki/Ecto-Basics •
https://changelog.com/208/ • https://www.youtube.com/watch?v=SJRfujy9vLA&feature=youtu.be&t=18m38s • https://www.youtube.com/watch?v=snka1bAtZS0
More Decks by Amanda
See All by Amanda
Lessons Learned From an Elixir OTP Project
amandasposito
2
110
Aprendizados de um projeto Elixir OTP
amandasposito
4
660
SOLID - Dependency inversion principle
amandasposito
0
110
Como concorrência funciona em Elixir?
amandasposito
1
250
Programação Funcional & Elixir
amandasposito
3
150
Novidades no Rails 5
amandasposito
0
110
Rails Engines & RSpec
amandasposito
0
260
Elixir e Phoenix
amandasposito
3
600
Elixir em 5 minutos
amandasposito
1
110
Other Decks in Technology
See All in Technology
市販IoT機器や自作IoT機器とHomeAssistantを駆使して家の電気代をできる限り見える化する方法の考案
harutiro
0
330
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
15
25k
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
6.5k
AI対話型分析を作成し、リリースするまでの話 / The Road to Release: Buiding AI Conversational Analytics
yappli_developers
0
150
AWS Client VPNの設定でハマったポイントとその過程での気づき
amarelo_n24
0
260
Biohub - Cell Tracking During Development 5th place solution
rist
0
170
「個社」ではなく「業界」の課題を解く AI 対話開発 ー 価値を広げる設計と、価値を守るエンジニアリング ー
ivry_presentationmaterials
2
150
これからのデータエンジニアの役割について考える / Rethinking the Role of Data Engineers in the AI Era
okiyuki99
0
530
エンタープライズ事業未経験のデータ屋、 AI時代にN回撃沈する.pdf
ryoskdara_
0
140
「任されビリティ」で引き受けて「よしなりてぃ」に頼らず任せる / Accept tasks with "makasarebility" and hand them over without relying on "yoshinarily"
pauli
1
730
業務の傍らで進める改善ループエンジニアリング
bengo4com
0
130
[関西Kaggler会 20261113] 続・コミュニティコンペのススメ
nejumi
0
120
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
280
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
320
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
480
My Coaching Mixtape
mlcsv
0
390
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
Optimising Largest Contentful Paint
csswizardry
37
4k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
980
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
490
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
580