当前位置: 首页 > news >正文

应用实战|从头开始开发记账本2:基于模板快速开始

上期视频我们创建好了BaaS服务的后端应用。从这期视频开始,我们将从头开发一个互联网记账本应用。本期视频我们介绍一下如何使用模板快速开启我们的应用开发之旅。

应用实战|从头开始开发记账本2:基于模板快速开始

相关代码

本期视频我们介绍了如何通过模板快速开始MemFire Cloud项目,简单了解了模板代码内置的功能,同时演示了一下如何配置并运行我们的模板代码。

新建应用

注册登录MemFire Cloud平台,创建一个应用;
在这里插入图片描述

React

npx create-react-app --template memfire-react-template <your_project_name>

Vue

vue create --preset memfire-cloud/memfire-vue-tempalte <your_project_name>

SQL创建

-- 创建用户信息表
CREATE TABLE "public"."profile" ( "id" uuid default uuid_generate_v4() primary key,"created_at" timestamp default now() ,"email" TEXT,"user_name" TEXT,"avatar" VARCHAR,"introduction" VARCHAR
);
-- 创建todo表
CREATE TABLE "public"."todo_list" ( "id" SERIAL,"created_at" timestamp default now() ,"user_id" uuid references public.profile not null,"todo" VARCHAR NOT NULL"completed" BOOLEAN NOT NULL,
);
-- 创建实时聊天记录表
CREATE TABLE "public"."messages" ( "id" SERIAL,"user_id" uuid references public.profile not null,"created_at" timestamp default now() ,"message" TEXT NOT NULL,"user_name" TEXT NOT NULL,"avatar" VARCHAR NOT NULL
);
-- Set up Row Level Security (RLS)
alter table todo_list enable row level security;-- 用户只能删改查自己的todo
create policy "Users can select their own todo_list."on todo_list for selectusing ( auth.uid() = user_id );create policy "Users can insert their own todo_list."on todo_list for insertwith check ( auth.uid() = user_id );create policy "Users can update own todo_list."on todo_list for updateusing ( auth.uid() = user_id );create policy "Users can delete own todo_list."on todo_list for deleteusing ( auth.uid() = user_id );-- 人员信息列表每个人都可以访问
alter table accountenable row level security;create policy "Public account are viewable by everyone." on accountfor select using (true);create policy "Users can insert their own account." on accountfor insert with check (true);create policy "Users can select their own account." on accountfor update using (true);create policy "Users can delete their own account." on accountfor delete using (true);-- 聊天信息表每个人都可以查询数据;只有用户自己才能发送消息。alter table messagesenable row level security;create policy "Public messages are viewable by everyone." on messagesfor select using (true);create policy "Users can insert their own messages." on messagesfor insert with check (auth.uid() = user_id);/*** REALTIME SUBSCRIPTIONS* 只允许在公共表进行实时监听。*/begin;-- remove the realtime publicationdrop publication if exists supabase_realtime;-- re-create the publication but don't enable it for any tablescreate publication supabase_realtime;
commit;-- add tables to the publication
alter publication supabase_realtime add table public.messages;-- 创建存储桶
insert into storage.buckets (id, name)values ('avatars', 'avatars');insert into storage.buckets (id, name)
values ('files', 'files');-- Set up access controls for storage.
create policy "files images are publicly accessible." on storage.objectsfor select using ( true );create policy "Own can upload an files." on storage.objectsfor insert with check (true);create policy "Own can update their own files." on storage.objectsfor update using ( true );create policy "Own can delete their own files." on storage.objectsfor delete using ( true);

下一期视频我们会带领大家快速了解一下平台提供的API,以及如何通过API文档来学习SDK的用法。我们下期再见。

http://www.lryc.cn/news/337729.html

相关文章:

  • 学习前端第二十天(条件分支:if 和 ‘?‘;逻辑运算符)
  • C++11的更新介绍(lamada、包装器)
  • Golang 实现一个简单的 RPC 服务
  • Linux系统(centos,redhat,龙芯,麒麟等)忘记密码,怎么设置新的密码
  • SpringBoot的启动原理
  • git查看单独某一个文件的历史修改记录
  • 一键开启Scrum回顾会议的精彩时刻
  • Python计算多个表格中多列数据的平均值与标准差并导出为新的Excel文件
  • nginx支持的多种负载均衡策略
  • FNP preptool has not been run on this executable
  • 算法-反转单向链表
  • Ps 滤镜:方框模糊
  • MTK Android13 霸屏实现
  • PyTorch神经网络打印存储所有权重+激活值(运行时中间值)
  • grpc-教程(golang版)
  • Spring与Spring Boot的区别:从框架设计到应用开发
  • React Hooks 全解: 常用 Hooks 及使用场景详解
  • 第十三届蓝桥杯真题:x进制减法,数组切分,gcd,青蛙过河
  • JavaEE初阶Day 6:多线程(4)
  • 微信小程序 django+nodejs电影院票务售票选座系统324kd
  • 基于springboot实现桂林旅游景点导游平台管理系统【项目源码+论文说明】计算机毕业设计
  • idea 开发serlvet汽车租赁管理系统idea开发sqlserver数据库web结构计算机java编程layUI框架开发
  • Unity之PUN实现多人联机射击游戏的优化(Section 3)
  • PDF锐化
  • 【python和java】
  • C盘满了怎么办,清理工具TreeSize
  • 【vue】watch 侦听器
  • 校招生如何准备软件测试、测试开发岗位的面试?
  • 蓝桥杯抱佛脚篇~
  • 基于springboot的大学城水电管理系统源码数据库