Upgrade to Pro — share decks privately, control downloads, hide ads and more …

EdgeDB–PyBay 2022

Yury Selivanov
September 11, 2022
260

EdgeDB–PyBay 2022

Yury Selivanov

September 11, 2022
Tweet

Transcript

  1. SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM Movie_Reviews WHERE

    movie_id = Movie.id) AS rating FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id WHERE 'Zendaya' IN ( SELECT Person.name FROM Movie_Actors INNER JOIN Person ON Movie_Actors.person_id = Person.id WHERE Movie_Actors.movie_id = Movie.id)
  2. SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM Movie_Reviews WHERE

    movie_id = Movie.id) AS rating FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id WHERE 'Zendaya' IN ( SELECT Person.name FROM Movie_Actors INNER JOIN Person ON Movie_Actors.person_id = Person.id WHERE Movie_Actors.movie_id = Movie.id) select Movie { title, actors: { name }, rating := math::mean(.reviews.score) } filter "Zendaya" in .actors.name; select Movie { title, actors: { name }, rating := math::mean(.reviews.score) } filter "Zendaya" in .actors.name;
  3. “Stockholm syndrome” was fi rst used by the media in

    1973 when four hostages were taken during a bank robbery in Stockholm, Sweden. The hostages defended their captors after being released and would not agree to testify in court against them.
  4. Query language SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM

    Movie_Reviews WHERE movie_id = Movie.id) AS rating FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id WHERE 'Zendaya' IN ( SELECT Person.name FROM Movie_Actors INNER JOIN Person ON Movie_Actors.person_id = Person.id WHERE Movie_Actors.movie_id = Movie.id) select Movie { title, actors: { name }, rating := math::mean(.reviews.score) } filter "Zendaya" in .actors.name; select Movie { title, actors: { name }, rating := math::mean(.reviews.score) } filter "Zendaya" in .actors.name;
  5. select Movie { title, actors: { name }, } SELECT

    title FROM Movie EdgeQL SQL 37 Query Example
  6. select Movie { title, actors: { name }, } SELECT

    title, Actors.name AS actor_name FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id EdgeQL SQL 38 [ { "title": "The Matrix", "actors": [ {"name": "Keanu Reeves"}, {"name": "Hugo Weaving"}, ] } ] [ { "title": "The Matrix", "actor_name": "Keanu Reeves", }, { "title": "The Matrix", "actor_name": "Hugo Weaving", }, ... ] Query Example
  7. select Movie { title, actors: { name }, rating :=

    math::mean(.reviews.score) } SELECT title, Actors.name AS actor_name FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id EdgeQL SQL 39 Query Example
  8. select Movie { title, actors: { name }, rating :=

    math::mean(.reviews.score) } SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM Movie_Reviews WHERE movie_id = Movie.id) AS rating FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id EdgeQL SQL 40 Query Example
  9. select Movie { title, actors: { name }, rating :=

    math::mean(.reviews.score) } filter "Zendaya" in .actors.name EdgeQL SQL 41 SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM Movie_Reviews WHERE movie_id = Movie.id) AS rating FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id Query Example
  10. select Movie { title, actors: { name }, rating :=

    math::mean(.reviews.score) } filter "Zendaya" in .actors.name SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM Movie_Reviews WHERE movie_id = Movie.id) AS rating FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id WHERE 'Zendaya' IN ( SELECT Person.name FROM Movie_Actors INNER JOIN Person ON Movie_Actors.person_id = person.id 
 WHERE Movie_Actors.movie_id = Movie.id ) EdgeQL SQL 42 Query Example
  11. EdgeQL SQL 43 select Movie { title, actors: { name

    } order by @credits_order limit 5, rating := math::mean(.reviews.score) } filter "Zendaya" in .actors.name SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM Movie_Reviews WHERE movie_id = Movie.id) AS rating FROM Movie LEFT JOIN Movie_Actors ON Movie.id = Movie_Actors.movie_id LEFT JOIN Person AS Actors ON Movie_Actors.person_id = Person.id WHERE 'Zendaya' IN ( SELECT Person.name FROM Movie_Actors INNER JOIN Person ON Movie_Actors.person_id = person.id 
 WHERE Movie_Actors.movie_id = Movie.id ) Query Example
  12. SELECT title, Actors.name AS actor_name, (SELECT avg(score) FROM Movie_Reviews WHERE

    movie_id = Movie.id) AS rating FROM Movie CROSS JOIN LATERAL ( SELECT name FROM Movie_Actors INNER JOIN Person ON Movie_Actors.person_id = Person.id WHERE Movie_Actors.movie_id = Movie.id ORDER BY Movie_Actors.credits_order FETCH FIRST 5 ROWS ONLY ) AS Actors WHERE 'Zendaya' IN ( SELECT Person.name FROM Movie_Actors INNER JOIN Person ON Movie_Actors.person_id = person.id WHERE Movie_Actors.movie_id = Movie.id ) EdgeQL SQL 44 select Movie { title, actors: { name } order by @credits_order limit 5, rating := math::mean(.reviews.score) } filter "Zendaya" in .actors.name Query Example
  13. EdgeQL with movie_actor_names := {"Robert Downey Jr.", "Chris Evans"}, actors

    := (select Person filter .name in movie_actor_names), avengers := (insert Movie { title := "Avengers", actors := actors }), endgame := (insert Movie { title := "Avengers: Endgame", actors := actors }), account := (select Account filter .login = <str>$login) update 
 account 
 set { 
 watch_list += {avengers, endgame} 
 }
  14. Client APIs select Movie { title, actors: { name },

    rating := math::mean(.reviews.score) } filter "Zendaya" in .actors.name; Fast Safe Zero-con fi g Easy Async or Sync
  15. WHY select Movie { title, actors: { name }, rating

    := math::mean(.reviews.score) } filter "Zendaya" in .actors.name; So that you write
 fast code fast
 while having 
 fun.
  16. select Movie { title, actors: { name }, rating :=

    math::mean(.reviews.score) } filter "Zendaya" in .actors.name; @1st1 on twitter edgedb.com We are hiring.