Skip to main content

Aggregate.skip

1. Interface Description

Function: Aggregation stage. Specifies a positive integer, skips the corresponding number of documents, and outputs the remaining documents.

Syntax: skip(<positive integer>)

2. Input Parameters

ParameterTypeRequiredDescription
-numberYesPositive integer, otherwise an error will occur.

3. Response

ParameterTypeRequiredDescription
-AggregateYesAggregation object

4. Sample Code

const tcb = require("@cloudbase/node-sdk");
const app = tcb.init({
env: "xxx",
});

const db = app.database();
const { gt, sum, concat } = db.command.aggregate;

exports.main = async (event, context) => {
const res = await db.collection("users").aggregate().skip(5).end();
console.log(res.data);
};

This code will skip the first 5 documents found and output the remaining documents.