Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Makes it easier to copy/paste the supascript

Paul Copplestonedede8172b0d4
diff --git a/www/_blog/2021-05-03-supabase-beta-april-2021.mdx b/www/_blog/2021-05-03-supabase-beta-april-2021.mdx
index 39c9c1c7f39..53654a9721e 100644
--- a/www/_blog/2021-05-03-supabase-beta-april-2021.mdx
+++ b/www/_blog/2021-05-03-supabase-beta-april-2021.mdx
@@ -39,7 +39,7 @@ We're a developer tool, which means that Dark Mode is [extremely popular](https:
While Dark mode is great, for some people it's not an option. Dark Mode is difficult to use for developers with astigmatisms,
or even just working in brightly-lit environments.
-So today we're shipping Light Mode. Access it in the settings of your [Dashboard](https://app.supabase.io)
+So today we're shipping Light Mode. Access it in the settings of your [Dashboard](https://app.supabase.io).
<video width="99%" autoPlay="autoplay" muted playsInline controls={true}>
<source src="/new/images/blog/april-2021/light-mode.mp4" type="video/mp4" muted playsInline />
@@ -80,7 +80,9 @@ We released [Storage Api docs](https://supabase.github.io/storage-api) built usi
## Stripe Sync Engine (Experimental)
-We [open-sourced a server](https://github.com/supabase/stripe-sync-engine) which keeps any Postgres database in sync with a Stripe account. This is experimental only. We're evaluating other tools such as [Singer](https://www.singer.io/tap/stripe/postgresql/), which provide a more general solution (but are less "realtime"), and we're opening it up here to gather feedback.
+We [open-sourced a server](https://github.com/supabase/stripe-sync-engine) which keeps any Postgres database in sync with Stripe.
+This is experimental only. We're evaluating other tools such as [Singer](https://www.singer.io/tap/stripe/postgresql/),
+which provide a more general solution (but are less "realtime"), and we're opening it up here to gather feedback.
![Stripe sync engine](/new/images/blog/april-2021/stripe-sync-engine.jpg)
@@ -94,9 +96,30 @@ One of the most powerful Postgres features is "recursive CTEs" which can be used
## Community spotlight: SupaScript
-It looks like [@burggraf2](https://twitter.com/burggraf2) got tired of waiting for us to ship Functions, and decided to build a whole JS ecosystem within his Supabase database. If you want to write PG functions in JS, import remote libraries from the web, and console log to your browser, check out this [SupaScript repo](https://github.com/burggraf/SupaScript).
-
-![SupaScript to lookup users in the past 1 week](/new/images/blog/april-2021/supascript.png)
+It looks like [@burggraf2](https://twitter.com/burggraf2) got tired of waiting for us to ship Functions, and decided to
+build a whole JS ecosystem within his Supabase database. If you want to write PG functions in JS, import remote libraries
+from the web, and console log to your browser, check out this [SupaScript repo](https://github.com/burggraf/SupaScript).
+
+```js
+// After installing:
+// https://github.com/burggraf/SupaScript#installation
+
+/**
+ * Get all users who logged in this week.
+ * Use in the database: select * from users_this_week();
+ * Use in the browser: supabase.rpc('users_this_week');
+ */
+create or replace function users_this_week()
+returns json as $$
+ const moment = require('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.js', false);
+
+ const lastWeek = moment().subtract(7, 'days');
+ const query = 'select * from auth.users where created_at > $1'
+ const users = sql(query, lastWeek);
+
+ return users;
+$$ language plv8;
+```
## Community spotlight: Fireship