连接数据库并修改页面
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { supabase, ensureSupabaseReady } from '@/components/supadb/aksupainstance.uts'
|
||||
import supabase, { supaReady } from '@/components/supadb/aksupainstance.uts'
|
||||
import type { DeviceInfo, DeviceParams } from './types.uts'
|
||||
|
||||
// 服务响应类型
|
||||
@@ -17,7 +17,7 @@ export class SenseDataService {
|
||||
*/
|
||||
static async getDevices(params: DeviceParams): Promise<ServiceResponse<Array<DeviceInfo>>> {
|
||||
try {
|
||||
await ensureSupabaseReady()
|
||||
await supaReady
|
||||
const res = await supabase.from(SenseDataService.TABLE_NAME)
|
||||
.select('*', {})
|
||||
.eq('user_id', params.user_id)
|
||||
@@ -46,7 +46,7 @@ export class SenseDataService {
|
||||
*/
|
||||
static async bindDevice(deviceData: UTSJSONObject): Promise<ServiceResponse<DeviceInfo>> {
|
||||
try {
|
||||
await ensureSupabaseReady()
|
||||
await supaReady
|
||||
const res = await supabase.from(SenseDataService.TABLE_NAME)
|
||||
.insert(deviceData)
|
||||
.select('*', {})
|
||||
@@ -75,7 +75,7 @@ export class SenseDataService {
|
||||
*/
|
||||
static async unbindDevice(deviceId: string): Promise<ServiceResponse<null>> {
|
||||
try {
|
||||
await ensureSupabaseReady()
|
||||
await supaReady
|
||||
const res = await supabase.from(SenseDataService.TABLE_NAME)
|
||||
.delete()
|
||||
.eq('id', deviceId)
|
||||
@@ -102,7 +102,7 @@ export class SenseDataService {
|
||||
*/
|
||||
static async updateDevice(deviceId: string, configData: UTSJSONObject): Promise<ServiceResponse<DeviceInfo>> {
|
||||
try {
|
||||
await ensureSupabaseReady()
|
||||
await supaReady
|
||||
const res = await supabase.from(SenseDataService.TABLE_NAME)
|
||||
.update(configData)
|
||||
.eq('id', deviceId)
|
||||
|
||||
Reference in New Issue
Block a user