Comparing version 0.8.4 to 0.8.5
{ | ||
"name": "notabase", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"description": "API Wrapper For Notion's Database", | ||
@@ -5,0 +5,0 @@ "main": "src/notabase.js", |
@@ -32,9 +32,15 @@ const utils = require('./utils') | ||
this.client.blockStore = { ...this.client.blockStore, ...rawData.recordMap.block } | ||
if (this.total > 980){ | ||
this.fetchMore(); | ||
} | ||
this.completed = false | ||
return (async () => { | ||
if (this.total > 980){ | ||
await this.fetchMore(); | ||
} | ||
this.completed = true; | ||
return this; | ||
})() | ||
} | ||
async fetchMore() { | ||
const data = await this.client.queryCollection(this.collectionId, this.collectionViewId, limit=this.total); | ||
const data = await this.client.queryCollection(this.collectionId, this.collectionViewId, this.total); | ||
const blockIds = data.result.blockIds.slice(980, this.total); | ||
@@ -41,0 +47,0 @@ const blocksDataList = await this.client.getRecordValues(blockIds, []); |
@@ -90,3 +90,3 @@ const Collection = require('./collection') | ||
let requestsIds = [...blockIds.map(item => ({ "table": "block", "id": item })), ...collectionIds.map(item => ({ "table": "collection", "id": item }))] | ||
console.log(`>>>> getRecordValues:${requestsIds}`) | ||
requestsIds.length > 10 ?console.log(`>>>> getRecordValues: ${requestsIds.length}`): console.log(`>>>> getRecordValues:${requestsIds}`) | ||
let data = await this.reqeust.post(`/api/v3/getRecordValues`, | ||
@@ -140,3 +140,3 @@ { | ||
this.collectionSchemaStore[collectionId] = schema | ||
return new Collection(collectionId, collectionViewId, data, this) | ||
return await new Collection(collectionId, collectionViewId, data, this) | ||
} | ||
@@ -143,0 +143,0 @@ async fetch(urlOrPageId) { |
@@ -47,7 +47,4 @@ const Notabase = require('../src/notabase') | ||
let db = await nb.fetch(testTable1Url); | ||
expect(db.rows.length).toBeGreaterThanOrEqual(980); | ||
expect(db.total).toBeGreaterThanOrEqual(1278); | ||
setTimeout(()=>{ | ||
expect(db.rows.length).toBeGreaterThanOrEqual(db.total); | ||
},1000); | ||
expect(db.rows.length).toBe(1278); | ||
expect(db.total).toBe(1278); | ||
}, 10000) |
40739
854