Kin*_*ld. 2 nosql firebase google-cloud-firestore
摘要:我想使用MySql和MongoDb中使用的“跳过”功能。但是,“startAfter(number)”不会跳过。
我现在正在制作一个公告板。然后我有一个问题。
这是一个跳页的问题。
我使用将页面直接移动给用户的基本方法。
但是,我找不到Mysql或MongoDB过去使用过的任何skip函数。
这是我的代码的一部分。
return db.collection('boards').doc(title).collection('posts')
.orderBy('date').startAfter(2).limit(10).get()
Run Code Online (Sandbox Code Playgroud)
所以我想从按日期排序的数据中跳过两个数据。
但是,“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);
});
Run Code Online (Sandbox Code Playgroud)
然而,上述方法非常麻烦,因为有可能无条件地拥有现有数据。
难道就没有什么好办法吗?我正在等待回复。
| 归档时间: |
|
| 查看次数: |
4487 次 |
| 最近记录: |