Initial commit of akmon project
This commit is contained in:
16
server/mqtt-simulator/create_rpc_function.sql
Normal file
16
server/mqtt-simulator/create_rpc_function.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- 在 Supabase SQL 编辑器中运行此 SQL 以创建 RPC 函数
|
||||
-- 解决 varchar 类型的 watch_id 无法直接通过 API 进行数值比较的问题
|
||||
|
||||
CREATE OR REPLACE FUNCTION get_sim_devices(min_id int)
|
||||
RETURNS TABLE (watch_id varchar)
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER -- 使用定义者的权限运行,绕过 RLS (如果需要)
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT d.watch_id
|
||||
FROM ak_devices d
|
||||
WHERE d.watch_id ~ '^[0-9]+$' -- 确保只选择纯数字的 ID
|
||||
AND d.watch_id::int > min_id; -- 转换为 int 进行比较
|
||||
END;
|
||||
$$;
|
||||
Reference in New Issue
Block a user