The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: ionic vue update (#35103)
hallidayofbc48bf8f253
diff --git a/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx b/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdxindex 937a170e67f..3499a0a2e27 100644--- a/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx+++ b/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx@@ -21,8 +21,7 @@ Let's start building the Vue app from scratch.### Initialize an Ionic Vue app-We can use the [Ionic CLI](https://ionicframework.com/docs/cli) to initialize-an app called `supabase-ionic-vue`:+We can use the [Ionic CLI](https://ionicframework.com/docs/cli) to initialize an app called `supabase-ionic-vue`:```bashnpm install -g @ionic/cli@@ -37,27 +36,27 @@ npm install @supabase/supabase-js```And finally we want to save the environment variables in a `.env`.+All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys).<$CodeTabs>```bash name=.env-VUE_APP_SUPABASE_URL=YOUR_SUPABASE_URL-VUE_APP_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY+VITE_SUPABASE_URL=YOUR_SUPABASE_URL+VITE_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY```</$CodeTabs>-Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposed-on the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.+Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposed on the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database.<$CodeTabs>-```js name=src/supabase.ts"+```js name=src/supabase.tsimport { createClient } from '@supabase/supabase-js';-const supabaseUrl = process.env.VUE_APP_SUPABASE_URL as string;-const supabaseAnonKey = process.env.VUE_APP_SUPABASE_ANON_KEY as string;+const supabaseUrl = import.meta.env.VITE_SUPABASE_URL as string;+const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY as string;export const supabase = createClient(supabaseUrl, supabaseAnonKey);```@@ -95,7 +94,7 @@ Let's set up a Vue component to manage logins and sign ups. We'll use Magic Link</div></form></ion-list>- <p>{{email}}</p>+ <p>{{ email }}</p></ion-content></ion-page></template>@@ -140,7 +139,7 @@ Let's set up a Vue component to manage logins and sign ups. We'll use Magic Linktry {await loader.present()- const { error } = await supabase.auth.signIn({ email: email.value })+ const { error } = await supabase.auth.signInWithOtp({ email: email.value })if (error) throw error@@ -183,21 +182,22 @@ Let's create a new component for that called `Account.vue`.<ion-item><ion-label><p>Email</p>- <p>{{ session?.user?.email }}</p>+ <p>{{ user?.email }}</p></ion-label></ion-item><ion-item><ion-label position="stacked">Name</ion-label>- <ion-input type="text" name="username" v-model="profile.username"></ion-input>+ <ion-input type="text" v-model="profile.username" /></ion-item><ion-item><ion-label position="stacked">Website</ion-label>- <ion-input type="url" name="website" v-model="profile.website"></ion-input>+ <ion-input type="url" v-model="profile.website" /></ion-item>+<div class="ion-text-center">- <ion-button fill="clear" type="submit">Update Profile</ion-button>+ <ion-button type="submit" fill="clear">Update Profile</ion-button></div></form>@@ -209,59 +209,62 @@ Let's create a new component for that called `Account.vue`.</template><script lang="ts">- import { store } from '@/store'- import { supabase } from '@/supabase'import {- IonContent,- IonHeader,IonPage,- IonTitle,+ IonHeader,IonToolbar,- toastController,- loadingController,- IonInput,+ IonTitle,+ IonContent,IonItem,- IonButton,IonLabel,+ IonInput,+ IonButton,+ toastController,+ loadingController,} from '@ionic/vue'- import { User } from '@supabase/supabase-js'import { defineComponent, onMounted, ref } from 'vue'+ import { useRouter } from 'vue-router'+ import { supabase } from '@/supabase'+ import type { User } from '@supabase/supabase-js'+export default defineComponent({name: 'AccountPage',components: {- IonContent,- IonHeader,IonPage,- IonTitle,+ IonHeader,IonToolbar,- IonInput,+ IonTitle,+ IonContent,IonItem,- IonButton,IonLabel,+ IonInput,+ IonButton,},setup() {- const session = ref(supabase.auth.session())+ const router = useRouter()+ const user = ref<User | null>(null)+const profile = ref({username: '',website: '',avatar_url: '',})- const user = store.user as User- async function getProfile() {- const loader = await loadingController.create({})++ const getProfile = async () => {+ const loader = await loadingController.create()const toast = await toastController.create({ duration: 5000 })await loader.present()+try {const { data, error, status } = await supabase.from('profiles')- .select(`username, website, avatar_url`)- .eq('id', user.id)+ .select('username, website, avatar_url')+ .eq('id', user.value?.id).single()if (error && status !== 406) throw errorif (data) {- console.log(data)profile.value = {username: data.username,website: data.website,@@ -277,20 +280,21 @@ Let's create a new component for that called `Account.vue`.}const updateProfile = async () => {- const loader = await loadingController.create({})+ const loader = await loadingController.create()const toast = await toastController.create({ duration: 5000 })+ await loader.present()+try {- await loader.present()const updates = {- id: user.id,+ id: user.value?.id,...profile.value,updated_at: new Date(),}- //+const { error } = await supabase.from('profiles').upsert(updates, {- returning: 'minimal', // Don't return the value after inserting+ returning: 'minimal',})- //+if (error) throw error} catch (error: any) {toast.message = error.message@@ -300,13 +304,15 @@ Let's create a new component for that called `Account.vue`.}}- async function signOut() {- const loader = await loadingController.create({})+ const signOut = async () => {+ const loader = await loadingController.create()const toast = await toastController.create({ duration: 5000 })await loader.present()+try {const { error } = await supabase.auth.signOut()if (error) throw error+ router.push('/')} catch (error: any) {toast.message = error.messageawait toast.present()@@ -315,10 +321,28 @@ Let's create a new component for that called `Account.vue`.}}- onMounted(() => {- getProfile()+ onMounted(async () => {+ const loader = await loadingController.create()+ await loader.present()++ const { data } = await supabase.auth.getSession()+ user.value = data.session?.user ?? null++ if (!user.value) {+ router.push('/')+ } else {+ await getProfile()+ }++ await loader.dismiss()})- return { signOut, profile, session, updateProfile }++ return {+ user,+ profile,+ updateProfile,+ signOut,+ }},})</script>@@ -351,7 +375,7 @@ const routes: Array<RouteRecordRaw> = []const router = createRouter({- history: createWebHistory(process.env.BASE_URL),+ history: createWebHistory(import.meta.env.BASE_URL),routes,})@@ -367,9 +391,7 @@ export default router<script lang="ts">import { IonApp, IonRouterOutlet, useIonRouter } from '@ionic/vue'- import { defineComponent } from 'vue'-- import { store } from './store'+ import { defineComponent, ref, onMounted } from 'vue'import { supabase } from './supabase'export default defineComponent({@@ -380,13 +402,24 @@ export default router},setup() {const router = useIonRouter()- store.user = supabase.auth.user() ?? {}- supabase.auth.onAuthStateChange((_, session) => {- store.user = session?.user ?? {}- if (session?.user) {- router.replace('/account')- }+ const user = ref(null)++ onMounted(() => {+ supabase.auth+ .getSession()+ .then((resp) => {+ user.value = resp.data.session?.user ?? null+ })+ .catch((err) => {+ console.log('Error fetching session', err)+ })++ supabase.auth.onAuthStateChange((_event, session) => {+ user.value = session?.user ?? null+ })})++ return { user }},})</script>@@ -424,7 +457,7 @@ With those packages installed we can update our `main.ts` to include an addition<$CodeTabs>-```ts name=src/main.tsx"+```ts name=src/main.tsximport { createApp } from 'vue'import App from './App.vue'import router from './router'diff --git a/packages/pg-meta/test/query/advanced-query.test.ts b/packages/pg-meta/test/query/advanced-query.test.tsindex 4366e608a5f..0af6aac201c 100644--- a/packages/pg-meta/test/query/advanced-query.test.ts+++ b/packages/pg-meta/test/query/advanced-query.test.ts@@ -199,9 +199,7 @@ describe('Advanced Query Tests', () => {const query = new Query()const sql = query.from('table with spaces', 'public').select('"quoted\'column"').toSql()- expect(sql).toMatchInlineSnapshot(- `"select "quoted'column" from public."table with spaces";"`- )+ expect(sql).toMatchInlineSnapshot(`"select "quoted'column" from public."table with spaces";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)expect(result[0]["quoted'column"]).toBe("value with 'quotes'")