gpt4 book ai didi

firebase - firestore 是否支持跳过功能?

转载 作者:行者123 更新时间:2023-12-02 03:35:34 25 4
gpt4 key购买 nike

<分区>

Summary: I want to use the 'skip' function used in MySql and MongoDb. However, 'startAfter (number)' does not skip.

我现在正在制作公告板。然后我有一个问题。

这是跳页的问题。

我使用的是直接向用户移动页面的基本方法。

然而,我找不到任何Mysql或MongoDB过去使用的跳过函数。

这是我的代码的一部分。

return db.collection('boards').doc(title).collection('posts')
.orderBy('date').startAfter(2).limit(10).get()

所以我想从按日期排序的数据中跳过两条数据。

但是,'startAfter'中的任何数字都将取自第一个数据。

当然,我在官方文档中查看了如下代码。

return first.get().then(function (documentSnapshots) {
// Get the last visible document
var lastVisible = documentSnapshots.docs[documentSnapshots.docs.length-1];
console.log("last", lastVisible);

// Construct a new query starting at this document,
// get the next 25 cities.
var next = db.collection("cities")
.orderBy("population")
.startAfter(lastVisible)
.limit(25);
});

但是,上面的方法很麻烦,因为有可能无条件的存在数据。

有没有什么好办法?我正在等待回复。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com