forked from gothinkster/realworld-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated List/Feed SQL notebook to work with seed data
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"cells":[{"kind":2,"language":"SQL++","value":"SELECT \r\n a.slug,\r\n a.title,\r\n a.description,\r\n a.body,\r\n a.tagList,\r\n a.createdAt,\r\n a.updatedAt,\r\n false AS favorited,\r\n a.favoritesCount,\r\n {\r\n \"username\": META(u).id,\r\n u.bio,\r\n u.image,\r\n \"following\": ARRAY_CONTAINS(COALESCE(fol,[]), META(u).id)\r\n } AS author,\r\n COUNT(*) OVER() AS articlesCount\r\n\r\nFROM Conduit._default.Articles a\r\nJOIN Conduit._default.Users u ON a.authorUsername = META(u).id\r\n\r\n\r\n/* these next lines are only for authenticated users */\r\n/* usernames need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favCurrent ON META(favCurrent).id = (\"mgroves\" || \":favorites\")\r\nLEFT JOIN Conduit._default.`Follows` fol ON META(fol).id = (\"mgroves\" || \"::follows\")\r\n\r\n/* for use with optional filter */\r\n/* username need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favFilter ON META(favFilter).id = (\"jake\" || \"::favorites\")\r\n\r\n/* convenience variable for getting the ArticleKey from slug */\r\nLET articleKey = SPLIT(a.slug, \"::\")[1]\r\n\r\nWHERE 1=1\r\n /* optional filters */\r\n /*AND ARRAY_CONTAINS(a.tagList, \"cruising\")\r\n AND a.authorUsername = 'user-u4tjaxvr.2lw'\r\n AND ARRAY_CONTAINS(favFilter, articleKey)\r\n AND ARRAY_CONTAINS(fol, a.authorUsername)*/ /* used for Feed endpoint */\r\n\r\nORDER BY COALESCE(a.updatedAt, a.createdAt) DESC\r\n\r\n/* needs parameterized */\r\nLIMIT 20\r\nOFFSET 0\r\n"}]} | ||
{"cells":[{"kind":2,"language":"SQL++","value":"SELECT \r\n a.slug,\r\n a.title,\r\n a.description,\r\n a.body,\r\n a.tagList,\r\n a.createdAt,\r\n a.updatedAt,\r\n false AS favorited,\r\n a.favoritesCount,\r\n {\r\n \"username\": META(u).id,\r\n u.bio,\r\n u.image,\r\n \"following\": ARRAY_CONTAINS(COALESCE(fol,[]), META(u).id)\r\n } AS author,\r\n COUNT(*) OVER() AS articlesCount\r\n\r\nFROM Conduit._default.Articles a\r\nJOIN Conduit._default.Users u ON a.authorUsername = META(u).id\r\n\r\n\r\n/* these next lines are only for authenticated users */\r\n/* usernames need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favCurrent ON META(favCurrent).id = (\"matt\" || \":favorites\")\r\nLEFT JOIN Conduit._default.`Follows` fol ON META(fol).id = (\"matt\" || \"::follows\")\r\n\r\n/* for use with optional filter */\r\n/* username need parameterized */\r\nLEFT JOIN Conduit._default.Favorites favFilter ON META(favFilter).id = (\"johnDoe\" || \"::favorites\")\r\n\r\n/* convenience variable for getting the ArticleKey from slug */\r\nLET articleKey = SPLIT(a.slug, \"::\")[1]\r\n\r\nWHERE 1=1\r\n /* optional filters */\r\n /*AND ARRAY_CONTAINS(a.tagList, \"cruising\")\r\n AND a.authorUsername = 'user-u4tjaxvr.2lw'\r\n AND ARRAY_CONTAINS(favFilter, articleKey)\r\n AND ARRAY_CONTAINS(fol, a.authorUsername)*/ /* used for Feed endpoint */\r\n\r\nORDER BY COALESCE(a.updatedAt, a.createdAt) DESC\r\n\r\n/* needs parameterized */\r\nLIMIT 20\r\nOFFSET 0\r\n"}]} |