首页 > 解决方案 > 如何从firebase数据库中的开始和结束索引中检索行

问题描述

我正在我的项目中尝试分页功能,我正在使用对 firebase 的反应。

我的问题陈述:如果我的数据库中有大约 50 条记录,如果我们要选择记录 3 - 8,查询是什么?

标签: reactjsfirebasefirebase-realtime-database

解决方案


如果您想在前端使用特定字段,请使用切片,我认为您可以从后端返回所有列表,然后从 ui 端切片。

let arr = [
{id:1,name:'One'},
{id:2,name:'Two'},
{id:3,name:'Three'},
{id:4,name:'Four'},
{id:5,name:'Five'},
{id:6,name:'Six'},
{id:7,name:'Seven'},
{id:8,name:'Eight'},
{id:9,name:'Nine'},
{id:10,name:'Ten'}
]
let selected = arr.slice(2,8);
console.log(selected)


推荐阅读