mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
🐛 Fix bug paginating databases and users (#1907)
This commit is contained in:
parent
c21c8b3369
commit
92a2e863f3
|
@ -52,6 +52,8 @@ export async function notionApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
|
|
||||||
export async function notionApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
export async function notionApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
|
const resource = this.getNodeParameter('resource', 0) as string;
|
||||||
|
|
||||||
const returnData: IDataObject[] = [];
|
const returnData: IDataObject[] = [];
|
||||||
|
|
||||||
let responseData;
|
let responseData;
|
||||||
|
@ -59,8 +61,11 @@ export async function notionApiRequestAllItems(this: IExecuteFunctions | ILoadOp
|
||||||
do {
|
do {
|
||||||
responseData = await notionApiRequest.call(this, method, endpoint, body, query);
|
responseData = await notionApiRequest.call(this, method, endpoint, body, query);
|
||||||
const { next_cursor } = responseData;
|
const { next_cursor } = responseData;
|
||||||
query['start_cursor'] = next_cursor;
|
if (resource === 'block' || resource === 'user') {
|
||||||
body['start_cursor'] = next_cursor;
|
query['start_cursor'] = next_cursor;
|
||||||
|
} else {
|
||||||
|
body['start_cursor'] = next_cursor;
|
||||||
|
}
|
||||||
returnData.push.apply(returnData, responseData[propertyName]);
|
returnData.push.apply(returnData, responseData[propertyName]);
|
||||||
if (query.limit && query.limit <= returnData.length) {
|
if (query.limit && query.limit <= returnData.length) {
|
||||||
return returnData;
|
return returnData;
|
||||||
|
|
|
@ -47,7 +47,6 @@ import {
|
||||||
databasePageFields,
|
databasePageFields,
|
||||||
databasePageOperations,
|
databasePageOperations,
|
||||||
} from './DatabasePageDescription';
|
} from './DatabasePageDescription';
|
||||||
import { getServers } from 'dns';
|
|
||||||
|
|
||||||
export class Notion implements INodeType {
|
export class Notion implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
|
@ -323,7 +322,6 @@ export class Notion implements INodeType {
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const body: IDataObject = {
|
const body: IDataObject = {
|
||||||
page_size: 100,
|
|
||||||
filter: { property: 'object', value: 'database' },
|
filter: { property: 'object', value: 'database' },
|
||||||
};
|
};
|
||||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
|
|
Loading…
Reference in a new issue