{"id":328866,"date":"2022-01-31T15:01:08","date_gmt":"2022-01-31T15:01:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=328866"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=328866","title":{"rendered":"<span>\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e Supabase. \u0427\u0430\u0441\u0442\u044c 1<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/pw\/hr\/ps\/pwhrpsl3_b_b80p3rzkdgc5yu_c.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/pw\/hr\/ps\/pwhrpsl3_b_b80p3rzkdgc5yu_c.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0438\u0437 2 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e <a href=\"https:\/\/supabase.com\/docs\"><code>Supabase<\/code><\/a> \u2014 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 (open source), \u0442.\u0435. \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0435 <a href=\"https:\/\/firebase.google.com\/\"><code>Firebase<\/code><\/a>. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0442\u0435\u043e\u0440\u0438\u0438, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043c\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 social app \u0441 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439, \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  <\/p>\n<p><strong>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Supabase?<\/strong><\/p>\n<p>  <\/p>\n<p><code>Supabase<\/code>, \u043a\u0430\u043a \u0438 <code>Firebase<\/code> \u2014 \u044d\u0442\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%BD%D0%BE%D0%B5_%D0%BE%D0%B1%D0%B5%D1%81%D0%BF%D0%B5%D1%87%D0%B5%D0%BD%D0%B8%D0%B5_%D0%BA%D0%B0%D0%BA_%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B0\"><code>SaaS<\/code><\/a> (software as a service \u2014 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0443\u0441\u043b\u0443\u0433\u0430) \u0438\u043b\u0438 <a href=\"https:\/\/ru.bmstu.wiki\/BaaS_(Backend-as-a-Service)\"><code>BaaS<\/code><\/a> (backend as a service \u2014 \u0431\u044d\u043a\u0435\u043d\u0434 \u043a\u0430\u043a \u0443\u0441\u043b\u0443\u0433\u0430). \u0427\u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442? \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 fullstack app \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c, \u0430 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>Supabase<\/code> \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f (SDK) \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (API). \u041f\u043e\u0434 &#171;\u0432\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c&#187; \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432), \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (PostgreSQL), \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, realtime (\u0440\u0435\u0430\u043a\u0446\u0438\u044e \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438), \u0438 \u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435 \u044d\u0442\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u0430 \u0436\u0435\u043b\u0430\u043d\u0438\u0435\u043c \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u044e (\u043d\u0443 \u043f\u043e\u0447\u0442\u0438) \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<p>  <\/p>\n<p><em>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">yarn add @supabase\/supabase-js<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0418\u043c\u043f\u043e\u0440\u0442<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import supabase from '@supabase\/supabase-js'<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"klient-client\">\u041a\u043b\u0438\u0435\u043d\u0442 (Client)<\/h2>\n<p>  <\/p>\n<p><em>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { createClient } from '@supabase\/supabase-js'  const supabase = createClient(url, key, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>url<\/code> \u2014 \u043f\u0443\u0442\u044c, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0430\u043d\u0435\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c;<\/li>\n<li><code>key<\/code> \u2014 \u043a\u043b\u044e\u0447, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0430\u043d\u0435\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c;<\/li>\n<li><code>options<\/code> \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">const options = {  \/\/ \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430  schema: 'public',  headers: { 'x-my-custom-header': 'my-app-name' },  autoRefreshToken: true,  persistSession: true,  detectSessionInUrl: true } const supabase = createClient('https:\/\/my-app.supabase.co', 'public-anon-key', options)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 <code>supabase-js<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/www.npmjs.com\/package\/cross-fetch\"><code>cross-fetch<\/code><\/a>. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const supabase = createClient('https:\/\/my-app.supabase.co', 'public-anon-key', {  fetch: fetch.bind(globalThis) })<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"autentifikaciya-auth\">\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f (Auth)<\/h2>\n<p>  <\/p>\n<p><strong>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>signUp<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function registerUser({ email, password, first_name, last_name, age }) {  try {    const { user, session, error } = await supabase.auth.signUp({      \/\/ \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e      email,      password    }, {      \/\/ \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e      data: {        \/\/ \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u0432 JS        \/\/ \u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0434\u043b\u044f Postgres        first_name,        last_name,        age      },      \/\/ \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430      redirectTo: window.location.origin    })    if (error) throw error    return { user, session }  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>React-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e `registerUser` \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f const onSubmit = (e) => {  e.preventDefault()  if (submitDisabled) return   setLoading(true)  userApi    .registerUser(formData)    .then(setUser)    .catch(setError)    .finally(() => {      setLoading(false)    }) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 <code>TypeScript<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function registerUser({ first_name, last_name, age, email, password }: UserData): ResponseData {  let data = { user: null, error: null }  try {    const { user, error } = await supabase.auth.signUp({      email,      password    }, {      data: {        first_name,        last_name,        age      }    })    if (error) {      data.error = error    } else {      data.user = user    }  } catch (e) {    data.error = e  } finally {    return data  } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0441\u0432\u043e\u0439 email. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <code>Authentication -> Settings<\/code>.<\/p>\n<p>  <\/p>\n<p><strong>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>signIn<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function loginUser({ email, password }) {  try {    const { user, session, error } = await supabase.auth.singIn({      \/\/ \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e      email,      password    }, {      \/\/ \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e      returnTo: window.location.pathname    })    if (error) throw error    return { user, session }  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 email, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f <code>\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430\/magic link<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 <code>GitHub<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function loginWithGitHub() {  try {    const { user, session, error } = await supabase.auth.signIn({      \/\/ \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c `google`, `github`, `gitlab` \u0438\u043b\u0438 `bitbucket`      provider: 'github'    }, {      scopes: 'repo gist'    })    if (error) throw error    \/\/ \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a `API` \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f `session.provider_token`    return { user, session }  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>signOut<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function logoutUser() {  try {    const { error } = await supabase.auth.signOut()    if (error) throw error  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>auth.api.signOut(jwt)<\/code>.<\/p>\n<p>  <\/p>\n<p><strong>\u0421\u0435\u0441\u0441\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>session<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const session = supabase.auth.session()<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c<\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>user<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const user = supabase.auth.user()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u0411\u0414 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>auth.api.getUser(jwt)<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>auth.api.getUserByCookie<\/code>.<\/p>\n<p>  <\/p>\n<p><strong>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>update<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function updateUser({ email, age }) {  try {    const { user, error } = await supabase.auth.update({      email    }, {      data: {        age      }    })    if (error) throw error    return user  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">supabase.auth.onAuthStateChange((event, session) => {  console.log(event, session) })<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0421\u0431\u0440\u043e\u0441 \u043f\u0430\u0440\u043e\u043b\u044f<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = supabase.auth.api.resetPasswordForEmail(email, { redirectTo: window.location.origin })<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430 email \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0441\u0431\u0440\u043e\u0441\u0430 \u043f\u0430\u0440\u043e\u043b\u044f. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043e\u043d \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <code>SITE_URL\/#access_token=X&amp;refresh_token=Y&amp;expires_in=Z&amp;token_type=bearer&amp;type=recovery<\/code>. \u041c\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c <code>type=recovery<\/code> \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0441\u0431\u0440\u043e\u0441\u0430 \u043f\u0430\u0440\u043e\u043b\u044f. \u0417\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>access_token<\/code> \u0438\u0437 <code>URL<\/code> \u0438 \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function resetPassword(access_token, new_password) {  try {    const { data, error } = await supabase.auth.api.updateUser(access_token, { password: new_password })    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"baza-dannyh-database\">\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (Database)<\/h2>\n<p>  <\/p>\n<p><strong>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 (\u0432\u044b\u0431\u043e\u0440\u043a\u0430) \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .select(column_names, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>table_name<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e);<\/li>\n<li><code>column_names<\/code> \u2014 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043e\u043a (\u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432) \u0438\u043b\u0438 <code>'*'<\/code> \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439;<\/li>\n<li><code>options<\/code> \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<br \/> \n<ul>\n<li><code>head<\/code> \u2014 \u0435\u0441\u043b\u0438 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>true<\/code>, \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f (\u0441\u043c. \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0438\u0436\u0435);<\/li>\n<li><code>count<\/code> \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435: <code>null | exact | planned | estimated<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getUsers() {  try {    const { data, error } = await supabase      .from('users')      .select('id, first_name, last_name, age, email')    if (error) throw error    return data  } catch (e) {    throw(e)  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f <code>1000<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445.<\/p>\n<p>  <\/p>\n<p><code>select()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438 (\u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043f\u043e\u0437\u0436\u0435).<\/p>\n<p>  <\/p>\n<p><em>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getUsersAndPosts() {  try {    const { data, error } = await supabase      .from('users')      .select(`        id,        first_name,        last_name,        age,        email,        posts (          id,          title,          content        )      `)    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0424\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (inner join)<\/em><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f (messages), \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c (username):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getMessagesByUsername(username) {  try {    const { data, error } = await supabase      .from('messages')      \/\/ \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f `!inner()`      .select('*, users!inner(*)')      .eq('users.username', username)    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getUsersAndUserCount() {  try {    const { data, error, count } = await supabase      .from('users')      \/\/ \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f `{ count: 'exact', head: true }`      .select('id, first_name, last_name, email', { count: 'exact' })    if (error) throw error    return { data, count }  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 <code>JSONB-\u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432<\/code><\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getUsersWithTheirCitiesByCountry(country) {  try {    const { data, error } = await supabase      .from('users')      .select(`        id, first_name, last_name, email,        address->city      `)      .eq('address->country', country)    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>CSV<\/code><\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getUsersInCSV() {  try {    const { data, error } = await supabase      .from('users')      .select()      .csv()    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0417\u0430\u043f\u0438\u0441\u044c (\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0432\u0441\u0442\u0430\u0432\u043a\u0430) \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .insert(data_array, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>table_name<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b;<\/li>\n<li><code>data_array<\/code> \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li><code>options<\/code> \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<br \/> \n<ul>\n<li><code>returning: 'minimal'<\/code> \u2014 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438;<\/li>\n<li><code>upsert: true<\/code> \u2014 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function createPost({ title, body, author_id }) {  try {    const { data, error } = await supabase      .from('posts')      .insert([{        title, body, author_id      }])     if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e `messages` - \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 `{ title, body, user_id, room_id }` async function saveMessagesForRoom(messages) {  try {    const { error } = await supabase      .from('messages')      .insert(messages, { returning: 'minimal' })    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>upsert: true<\/code> \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <code>\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0435 \u0438\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438\/primary keys<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>  <\/p>\n<p><strong>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .update({ column_name: 'column_value' }, options)  .match(condition)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>table_name<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b;<\/li>\n<li><code>column_name: 'column_value'<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438 \u0435\u0435 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435;<\/li>\n<li><code>options<\/code> \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<br \/> \n<ul>\n<li><code>returning<\/code> \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f: <code>minimal | presentation<\/code>;<\/li>\n<li><code>count<\/code> \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a;<\/li>\n<\/ul>\n<\/li>\n<li><code>condition<\/code> \u2014 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function updateUser({ changes, user_id }) {  try {    const { data, error } = await supabase      .from('users')      .update({ ...changes })      .match({ id: user_id })    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u043c\u0435\u0442\u043e\u0434 <code>update<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f <code>JSON-\u043a\u043e\u043b\u043e\u043d\u043a\u0438<\/code><\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function updateUsersCity({ address, user_id }) {  try {    const { error } = await supabase      .from('users')      .update(`address: ${address}`, { returning: 'minimal' })      .match({ id: user_id })    if (error) throw error  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<p>  <\/p>\n<p><em>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445<\/em><\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .upsert({ primary_key_name: 'primary_key_value', column_name: 'column_value' }, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>options<\/code> \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<br \/> \n<ul>\n<li><code>returning<\/code>;<\/li>\n<li><code>count<\/code>;<\/li>\n<li><code>onConflict: string<\/code> \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438, \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 <code>UNIQUE<\/code>;<\/li>\n<li><code>ignoreDuplicates: boolean<\/code> \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u0438 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function updateOrCreatePost({ id, title, body, author_id }) {  try {    const { data, error } = await supabase      .from('posts')      .upsert({ id, title, body, author_id })    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0437\u0430 \u0440\u0430\u0437.<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em> \u043d\u0430 2 \u0432\u0435\u0449\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438;<\/li>\n<li>\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u043c\u0438 (\u043d\u0435 \u0441\u0443\u0440\u0440\u043e\u0433\u0430\u0442\u043d\u044b\u043c\u0438).<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .delete(options)  .match(condition)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>options<\/code>:<br \/> \n<ul>\n<li><code>returning<\/code>;<\/li>\n<li><code>count<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function removeUser(user_id) {  try {    const { error } = await supabase      .from('users')      .delete({ returning: 'minimal' })      .match({ id: user_id })    if (error) throw error  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 Postgres<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .rpc(fn, params, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>fn<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438;<\/li>\n<li><code>params<\/code> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438;<\/li>\n<li><code>options<\/code>:<br \/> \n<ul>\n<li><code>head<\/code>;<\/li>\n<li><code>count<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"sql\">CREATE FUNCTION check_password(username_or_email TEXT, password_hash TEXT) RETURNS BOOLEAN AS $$ DECLARE is_password_correct BOOLEAN; BEGIN  SELECT (hashed_password = $2) INTO is_password_correct  FROM users  WHERE username = $1 OR email = $1;  RETURN is_password_correct; END; $$ LANGUAGE plpgsql<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function checkPassword(username_or_email, password) {  let password_hash  try {    password_hash = await bcrypt.hash(password, 10)  } catch (e) {    throw e  }   try {    const { data, error } = await supabase      .rpc('check_password', { username_or_email, password_hash })    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>rpc<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .rpc('get_all_cities')  .select('city_name', 'population')  .eq('city_name', 'The Shire')<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"modifikatory-modifiers\">\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b (Modifiers)<\/h2>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (<code>select<\/code>). \u041e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>rpc<\/code>, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>  <\/p>\n<p><strong><code>limit()<\/code><\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>limit<\/code> \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .select(column_names)  .limit(count, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>count<\/code>: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u043e\u043a;<\/li>\n<li><code>options<\/code>:<br \/> \n<ul>\n<li><code>foreignTable<\/code>: \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 (\u0434\u043b\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043a\u043b\u044e\u0447\u043e\u043c).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getTop10Users() {  try {    const { data, error } = await supabase      .from('users')      .select('id, user_name, email')      .limit(10)    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getTop10CitiesByCountry(country_name) {  try {    const { data, error } = await supabase      .from('countries')      .select('country_name, cities(city_name)')      .eq('country_name', 'Rus')      .limit(10, { foreignTable: 'cities' })    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong><code>order()<\/code><\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>order<\/code> \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .select(column_names)  .order(column_name, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>column_name<\/code>: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430;<\/li>\n<li><code>options<\/code>:<br \/> \n<ul>\n<li><code>ascending<\/code>: \u0435\u0441\u043b\u0438 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>true<\/code>, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e;<\/li>\n<li><code>nullsFirst<\/code>: \u0435\u0441\u043b\u0438 <code>true<\/code>, \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <code>null<\/code> \u0438\u0434\u0443\u0442 \u0432\u043f\u0435\u0440\u0435\u0434\u0438;<\/li>\n<li><code>foreignTable<\/code>: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getMostLikedPosts(limit) {  try {    const { data, error } = await supabase      .from('posts')      .select()      .order('like_count', { ascending: true })      .limit(limit)    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong><code>range()<\/code><\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>range<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0441\u0442\u0440\u043e\u043a (\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e).<\/p>\n<p>  <\/p>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from(table_name)  .select(column_names)  .range(start, end, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>start<\/code>: \u043d\u0430\u0447\u0430\u043b\u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430;<\/li>\n<li><code>end<\/code>: \u043a\u043e\u043d\u0435\u0446 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430;<\/li>\n<li><code>options<\/code>:<br \/> \n<ul>\n<li><code>foreignTable<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getPostSlice(from, to) {  try {    const { data, error } = await supabase      .from('posts')      .select()      .range(from, to)    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong><code>single()<\/code><\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>single<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getUserById(user_id) {  try {    \/\/ \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430    const { data, error } = await supabase      .from('users')      .select('id, user_name, email')      .eq('id', user_id)      .single()    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>maybeSingle<\/code>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"filtry-filters\">\u0424\u0438\u043b\u044c\u0442\u0440\u044b (Filters)<\/h2>\n<p>  <\/p>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 <code>select<\/code>, <code>update<\/code> \u0438 <code>delete<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>rpc<\/code>, \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>  <\/p>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from('cities')  .select()  .eq('id', '1342')  .single()  const { data, error } = await supabase  .from('cities')  .select()  .gte('population', 1000)  .lt('population', 10000)  const filterByName = null const filterPopLow = 1000 const filterPopHigh = 10000  let query = supabase  .from('cities')  .select()  if (filterByName)  { query = query.eq('name', filterByName) } if (filterPopLow)  { query = query.gte('population', filterPopLow) } if (filterPopHigh) { query = query.lt('population', filterPopHigh) }  const { data, error } = await query<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0438\u0434\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>or('filter1, filter2, ...filterN', { foreignTable })<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>or('population.gt.1000, population.lte.100000')<\/code>; \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c <code>and<\/code>;<\/li>\n<li><code>not(column_name, operator, value)<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>not('population', 'gte', 100000)<\/code>;<\/li>\n<li><code>match(query)<\/code> \u2014 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0442\u043e\u0447\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>match({ user_name: 'Harry', life_style: 'webdev' })<\/code>;<\/li>\n<li><code>eq(column_name, column_value)<\/code> \u2014 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>eq('user_name', 'Harry')<\/code><\/li>\n<li><code>neq(column_name, column_value)<\/code> \u2014 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c <code>eq<\/code>;<\/li>\n<li><code>gt(column_name, value)<\/code> \u2014 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0447\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 (greater than), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>gt('age', 17)<\/code>;<\/li>\n<li><code>gte(column_name, value)<\/code>, <code>lt(column_name, value)<\/code>, <code>lte(column_name, value)<\/code> \u2014 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e, \u043c\u0435\u043d\u044c\u0448\u0435 \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e;<\/li>\n<li><code>like(column_name, pattern)<\/code> \u0438 <code>ilike(column_name, pattern)<\/code> \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c (\u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>like('user_name', '%oh%')<\/code> ;<\/li>\n<li><code>is(column_name, value)<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>is('married', false)<\/code>;<\/li>\n<li><code>in(column_name, column_value[])<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u0441 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>in('city_name', ['Paris', 'Tokyo'])<\/code>;<\/li>\n<li><code>contains(column_name, [column_value])<\/code> \u2014 <code>contains('main_lang', ['javascript'])<\/code>;<\/li>\n<li><code>overlaps(column_name, column_value[])<\/code> \u2014 <code>overlaps('hobby', ['code', 'guitar'])<\/code>;<\/li>\n<li><code>textSearch(column_name, query, options)<\/code> \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 <code>to_tsquery<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from('quotes')  .select('catchphrase')  .textSearch('catchphrase', `'fat' &amp; 'cat'`, {    config: 'english'  })<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>type<\/code>, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <code>plain<\/code> \u0438 <code>phrase<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0435 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0438 \u043f\u043e\u043b\u043d\u0443\u044e \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<ul>\n<li><code>filter(column_name, operator, value)<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0443. <code>filter<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043a\u043e\u0433\u0434\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .from('cities')  .select('city_name, countries(city_name)')  .filter('countries.city_name', 'in', '(\"France\", \"Japan\")')<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0440\u0443\u0433\u0438\u0445 (\u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445) \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<h2 id=\"hranilische-storage\">\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (Storage)<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f <em>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f<\/em> \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>createBucket<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function createAvatarBucket() {  try {    const { data, error } = await supabase      .storage      \/\/ createBucket(id, options)      .createBucket('avatars', { public: false })    if (error) throw error    return data  } catch (e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f (permissions policy):<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>insert<\/code>;<\/li>\n<li><code>objects<\/code>: <code>none<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 <code>Supabase<\/code> \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 <a href=\"https:\/\/postgrespro.ru\/docs\/postgrespro\/9.6\/ddl-rowsecurity\">row level security<\/a> (\u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0437\u0430\u0449\u0438\u0442\u044b \u0441\u0442\u0440\u043e\u043a). \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f <em>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/em> \u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>getBucket<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .storage  \/\/ getBucket(id)  .getBucket('avatars')<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>select<\/code>;<\/li>\n<li><code>objects<\/code>: <code>none<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f <em>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430<\/em> \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>listBuckets<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .storage  .listBuckets()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>updateBucket(id, options)<\/code> (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 <code>buckets<\/code>: <code>update<\/code>), \u0430 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u2014 \u043c\u0435\u0442\u043e\u0434 <code>deleteBucket(id)<\/code> (<code>buckets<\/code>: <code>select<\/code> \u0438 <code>delete<\/code>).<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0431\u0435\u0437 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>emptyBucket(id)<\/code> (<code>buckets<\/code>: <code>select<\/code>, <code>objects<\/code>: <code>select<\/code> \u0438 <code>delete<\/code>).<\/p>\n<p>  <\/p>\n<p><strong>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>upload<\/code>.<\/p>\n<p>  <\/p>\n<p><em>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">await supabase  .storage  .from(bucket_name)  .upload(path, file, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>bucket_name<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430;<\/li>\n<li><code>path<\/code> \u2014 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443. \u0414\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442 <code>folder\/subfolder\/fileName.fileExtension<\/code>. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430;<\/li>\n<li><code>file<\/code> \u2014 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0444\u0430\u0439\u043b: ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | ReadableStream | URLSearchParams | string (\u0442.\u0435. \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e);<\/li>\n<li><code>options<\/code> \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<br \/> \n<ul>\n<li><code>cacheControl<\/code>: HTTP-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a <code>Cache-Control<\/code>;<\/li>\n<li><code>contentType<\/code>: \u0442\u0438\u043f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>text\/plain;charset=utf-8<\/code>;<\/li>\n<li><code>upsert<\/code>: \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 (upsert) \u0444\u0430\u0439\u043b\u0430.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>none<\/code>;<\/li>\n<li><code>objects<\/code>: <code>insert<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function uploadAvatar({ userId, file }) {  \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430  const fileExt = file.name.split('.')[1]  try {    const { data, error } = await supabase      .storage      .from('users')      .upload(`avatars\/${userId}.${fileExt}`, file, {        cacheControl: '3600',        upsert: false      })    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>download<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function downloadFile({ bucketName, filePath }) {  try {    const { data, error } = await supabase      .storage      .from(bucketName)      .download(filePath)    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>none<\/code>;<\/li>\n<li><code>objects<\/code>: <code>select<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>list<\/code>.<\/p>\n<p>  <\/p>\n<p><em>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">list(dir_name, options, parameters)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>dir_name<\/code>: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438;<\/li>\n<li><code>options<\/code>:<br \/> \n<ul>\n<li><code>limit<\/code>: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432;<\/li>\n<li><code>offset<\/code>: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432;<\/li>\n<li><code>sortBy<\/code>:<\/li>\n<li><code>column_name<\/code>: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438;<\/li>\n<li><code>order<\/code>: \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438.<\/li>\n<\/ul>\n<\/li>\n<li><code>parameters<\/code>:<br \/> \n<ul>\n<li><code>signal<\/code>: <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/AbortController\/signal\"><code>AbortController.signal<\/code><\/a>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getAvatars({ limit = 100, offset = 0, sortBy = { column: 'name', order: 'asc' } }) {  try {    const { data, error } = await supabase      .storage      .from('users')      .list('avatars', {        limit,        offset,        sortBy      })    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>none<\/code>;<\/li>\n<li><code>objects<\/code>: <code>select<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>update<\/code>.<\/p>\n<p>  <\/p>\n<p><em>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">update(path, file, options)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>options<\/code>: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u043c <code>upload<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const defaultUpdateAvatarOptions = { cacheControl: '3600', upsert: false } async function updateAvatar({ filePath, file, options = defaultUpdateAvatarOptions }) {  try {    const { data, error } = await supabase      .storage      .from('users')      .update(`avatars\/${filePath}`, file, options)    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>none<\/code>;<\/li>\n<li><code>objects<\/code>: <code>select<\/code> \u0438 <code>update<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0441 \u0435\u0433\u043e \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>move<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const { data, error } = await supabase  .storage  .from('avatars')  .move('public\/avatar1.png', 'private\/moved_avatar.png')<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>none<\/code>;<\/li>\n<li><code>objects<\/code>: <code>select<\/code> \u0438 <code>update<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>remove<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0434\u0430\u043b\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 - \u043c\u0430\u0441\u0441\u0438\u0432 `filePathArr` async function removeFile({ bucketName, filePathArr }) {  try {    const { data, error } = await supabase      .storage      .from(bucketName)      .remove(filePathArr)    if (error) throw error    return data  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>none<\/code>;<\/li>\n<li><code>objects<\/code>: <code>select<\/code> \u0438 <code>delete<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0443\u0442\u0438 \u043a \u0444\u0430\u0439\u043b\u0443<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u043a \u0444\u0430\u0439\u043b\u0443 \u0431\u0435\u0437 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>createSignedUrl<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">createSignedUrl(path, expiresIn)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>expiresIn<\/code> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0441\u044b\u043b\u043a\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0439.<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getSignedUrl({ bucketName, filePath, expiresIn = 60 }) {  try {    const { signedUrl, error } = await supabase      .storage      .from(bucketName)      .createSignedUrl(filePath, expiresIn)    if (error) throw error    return signedUrl  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>buckets<\/code>: <code>none<\/code>;<\/li>\n<li><code>objects<\/code>: <code>select<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u043a \u0444\u0430\u0439\u043b\u0443, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443\u0441\u044f \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>getPublicUrl<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function getFileUrl({ bucketName, filePath }) {  try {    const { publicUrl, error } = supabase      .storage      .from(bucketName)      .getPublicUrl(filePath)    if (error) throw error    return publicUrl  } catch(e) {    throw e  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"registraciya-izmeneniy-dannyh-v-rezhime-realnogo-vremeni-realtime\">\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (Realtime)<\/h2>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0411\u0414, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>subscribe<\/code> \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>on<\/code>.<\/p>\n<p>  <\/p>\n<p><em>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const subscription = supabase  .from(table_name)  .on(event, callback)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>event<\/code> \u2014 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. \u0414\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>'*'<\/code>;<\/li>\n<li><code>callback<\/code> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>realtime<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438;<\/li>\n<li>\u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c &#171;\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435&#187; \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0439, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <code>REPLICA IDENTITY<\/code> \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>FULL<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>ALTER TABLE table_name REPLICA IDENTITY FULL;<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/em><\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const subscription = supabase  .from('*')  .on('*', payload => {    console.log('***', payload)  })  .subscribe()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const subscription = supabase  .from('posts')  .on('*', payload => {    console.log('***', payload)  })  .subscribe()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const subscription = supabase  .from('posts')  \/\/ INSERT | UPDATE | DELETE  .on('INSERT', payload => {    console.log('***', payload)  })  .subscribe()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const subscription = supabase  .from('posts')  .on('INSERT', insertHandler)  .on('DELETE', deleteHandler)  .subscribe()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">table_name:column_name=eq.value<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>table_name<\/code>: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b;<\/li>\n<li><code>column_name<\/code>: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438;<\/li>\n<li><code>value<\/code>: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">const subscription = supabase  .from('countries.id=eq.123')  .on('UPDATE', onUpdate)  .subscribe()<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041e\u0442\u043f\u0438\u0441\u043a\u0430 \u043e\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439<\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>removeSubscription<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">supabase.removeSubscription(subscription_name)<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>subscription_name<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f <code>WebSocket-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>removeAllSubscriptions<\/code>.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>getSubscriptions<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const allSubscriptions = supabase.getSubscriptions()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0435\u043c \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/cloud.timeweb.com\/?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign=cloud&amp;utm_content=direct&amp;utm_term=low\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/wn\/cq\/lp\/wncqlp9abeml4npwzsybuvhzcta.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/648761\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/648761\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/pw\/hr\/ps\/pwhrpsl3_b_b80p3rzkdgc5yu_c.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/pw\/hr\/ps\/pwhrpsl3_b_b80p3rzkdgc5yu_c.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0438\u0437 2 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e <a href=\"https:\/\/supabase.com\/docs\"><code>Supabase<\/code><\/a> \u2014 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 (open source), \u0442.\u0435. \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0435 <a href=\"https:\/\/firebase.google.com\/\"><code>Firebase<\/code><\/a>. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0442\u0435\u043e\u0440\u0438\u0438, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043c\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 social app \u0441 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439, \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  <\/p>\n<p><strong>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Supabase?<\/strong><\/p>\n<p>  <\/p>\n<p><code>Supabase<\/code>, \u043a\u0430\u043a \u0438 <code>Firebase<\/code> \u2014 \u044d\u0442\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%BD%D0%BE%D0%B5_%D0%BE%D0%B1%D0%B5%D1%81%D0%BF%D0%B5%D1%87%D0%B5%D0%BD%D0%B8%D0%B5_%D0%BA%D0%B0%D0%BA_%D1%83%D1%81%D0%BB%D1%83%D0%B3%D0%B0\"><code>SaaS<\/code><\/a> (software as a service \u2014 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0443\u0441\u043b\u0443\u0433\u0430) \u0438\u043b\u0438 <a href=\"https:\/\/ru.bmstu.wiki\/BaaS_(Backend-as-a-Service)\"><code>BaaS<\/code><\/a> (backend as a service \u2014 \u0431\u044d\u043a\u0435\u043d\u0434 \u043a\u0430\u043a \u0443\u0441\u043b\u0443\u0433\u0430). \u0427\u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442? \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 fullstack app \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c, \u0430 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>Supabase<\/code> \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f (SDK) \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (API). \u041f\u043e\u0434 &#171;\u0432\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c&#187; \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432), \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (PostgreSQL), \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, realtime (\u0440\u0435\u0430\u043a\u0446\u0438\u044e \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438), \u0438 \u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435 \u044d\u0442\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-328866","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=328866"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328866\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}