我尝试使用flutter从Supabase打印出多个数据,但就是不起作用
getResponse(String uid) async {
await client
.from("privChatRoom")
.select()
.eq('userID', uid)
.single()
.execute()
.then((value) {
if (value.error == null) {
print('value.data: ${value.data}');
} else {
print(value.error.message.toString());
print(value.error.hint.toString());
}
});
}
这是我每次运行此函数时收到的错误
I/flutter ( 2326): JSON object requested, multiple (or no) rows returned
I/flutter ( 2326): null
我有多行具有相同的uid,请告诉我如何获取它
编辑:找到了我必须删除.single()
的答案
发布于 2021-10-14 14:36:02
我不是flutter用户,但使用.single()
的工作方式应该与在Javascript客户端中相同。
.limit(1)
<=以数组[{id:123,firstname:'Harry',lastname:'Styles'}]
的形式返回单个记录
.single()
<=将单个记录作为对象{id:123,firstname:'Harry',lastname:'Styles'}
返回
https://stackoverflow.com/questions/68572506
复制相似问题