Commit f97eb088 authored by Andrew Biryukov's avatar Andrew Biryukov
Browse files

add sql script

parent 321f0f25
......@@ -4,8 +4,8 @@ import 'package:supabase_flutter/supabase_flutter.dart';
Future<GotrueSessionResponse> signUpUser(
String email, String password, int age, String city, String info) async {
final user = await Supabase.instance.client.auth.signUp(email, password);
final response = await Supabase.instance.client.from('UserData').insert([
{"user_id": user.user?.id, "Age": age, "City": city, "Info": info}
final response = await Supabase.instance.client.from('userdata').insert([
{"user_id": user.user?.id, "age": age, "city": city, "info": info}
]).execute();
print(response.error);
......
......@@ -104,13 +104,13 @@ class _UserPageState extends State<UserPage> {
Future<void> getUserAge() async {
var curUserId = Supabase.instance.client.auth.user()?.id;
final response = await Supabase.instance.client
.from('UserData')
.select('Age')
.from('userdata')
.select('age')
.eq('user_id', curUserId)
.execute();
if (mounted) { // check whether the state object is in tree
setState(() {
_userAge = response.data[0]['Age'];
_userAge = response.data[0]['age'];
});
}
}
......@@ -118,13 +118,13 @@ class _UserPageState extends State<UserPage> {
Future<void> getUserCity() async {
var curUserId = Supabase.instance.client.auth.user()?.id;
final response = await Supabase.instance.client
.from('UserData')
.select('City')
.from('userdata')
.select('city')
.eq('user_id', curUserId)
.execute();
if (mounted) {
setState(() {
_userCity = response.data[0]['City'];
_userCity = response.data[0]['city'];
});
}
}
......@@ -132,13 +132,13 @@ class _UserPageState extends State<UserPage> {
Future<void> getUserInfo() async {
var curUserId = Supabase.instance.client.auth.user()?.id;
final response = await Supabase.instance.client
.from('UserData')
.select('Info')
.from('userdata')
.select('info')
.eq('user_id', curUserId)
.execute();
if (mounted) {
setState(() {
_userInfo = response.data[0]['Info'];
_userInfo = response.data[0]['info'];
});
}
}
......
create table UserData (
user_id uuid primary key,
Age int,
City text,
Info text
);
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment