Comparing version 0.8.5 to 0.8.6
{ | ||
"name": "notabase", | ||
"version": "0.8.5", | ||
"version": "0.8.6", | ||
"description": "API Wrapper For Notion's Database", | ||
@@ -5,0 +5,0 @@ "main": "src/notabase.js", |
@@ -90,3 +90,3 @@ const Collection = require('./collection') | ||
let requestsIds = [...blockIds.map(item => ({ "table": "block", "id": item })), ...collectionIds.map(item => ({ "table": "collection", "id": item }))] | ||
requestsIds.length > 10 ?console.log(`>>>> getRecordValues: ${requestsIds.length}`): 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`, | ||
@@ -114,17 +114,17 @@ { | ||
async queryCollection(collectionId, collectionViewId, limit=980) { | ||
return await this.reqeust.post(`/api/v3/queryCollection`, { | ||
collectionId, | ||
collectionViewId, | ||
loader: { | ||
"type": "table", | ||
"limit": limit, | ||
"userTimeZone": "Asia/Shanghai", | ||
"userLocale": "zh-tw", | ||
"loadContentCover": true | ||
} | ||
}) | ||
async queryCollection(collectionId, collectionViewId, limit = 980) { | ||
return await this.reqeust.post(`/api/v3/queryCollection`, { | ||
collectionId, | ||
collectionViewId, | ||
loader: { | ||
"type": "table", | ||
"limit": limit, | ||
"userTimeZone": "Asia/Shanghai", | ||
"userLocale": "zh-tw", | ||
"loadContentCover": true | ||
} | ||
}) | ||
} | ||
async fetchCollectionData(collectionId, collectionViewId, limit=980) { | ||
async fetchCollectionData(collectionId, collectionViewId, limit = 980) { | ||
let data = await this.queryCollection(collectionId, collectionViewId, limit); | ||
@@ -147,22 +147,13 @@ console.log(`>>>> queryCollection:${collectionId}`) | ||
// pageId with '-' split | ||
pageId = getBlockHashId(urlOrPageId) | ||
if (pageId && pageId in this.collectionStore) { | ||
return this.collectionStore[pageId] | ||
} else { | ||
[collectionId, collectionViewId] = await this.getPageCollectionInfo(getBlockHashId(urlOrPageId)) | ||
} | ||
// pageId = getBlockHashId(urlOrPageId) | ||
[collectionId, collectionViewId] = await this.getPageCollectionInfo(getBlockHashId(urlOrPageId)) | ||
} else if (urlOrPageId.startsWith("http")) { | ||
// url | ||
pageId = getUrlPageId(urlOrPageId) | ||
if (pageId && pageId in this.collectionStore) { | ||
return this.collectionStore[pageId] | ||
} else { | ||
let [base, params] = urlOrPageId.split('?') | ||
let baseUrlList = base.split('/'); // 这里需要添加分号,否则编译出错。 参见 https://www.zhihu.com/question/20298345/answer/49551142 | ||
[collectionId, collectionViewId] = await this.getPageCollectionInfo(baseUrlList[baseUrlList.length - 1]) | ||
} | ||
// pageId = getUrlPageId(urlOrPageId) | ||
let [base, params] = urlOrPageId.split('?') | ||
let baseUrlList = base.split('/'); // 这里需要添加分号,否则编译出错。 参见 https://www.zhihu.com/question/20298345/answer/49551142 | ||
[collectionId, collectionViewId] = await this.getPageCollectionInfo(baseUrlList[baseUrlList.length - 1]) | ||
} | ||
let r = await this.fetchCollectionData(collectionId, collectionViewId) | ||
this.collectionStore[pageId] = r | ||
// this.collectionStore[pageId] = r | ||
return r | ||
@@ -169,0 +160,0 @@ } |
40460
846