Skip to content

Commit

Permalink
Replaced queryCollection and syncRecordValues with loadPageChunk (#12)
Browse files Browse the repository at this point in the history
* Replaced queryCollection and syncRecordValues with loadPageChunk

* Fixed loadPageChunk payload
  • Loading branch information
Devorein committed Mar 15, 2021
1 parent f661f89 commit b6357ad
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions api/table-description.js
Expand Up @@ -14,17 +14,25 @@ module.exports = async (req, res) => {
})
}

const pageData = await call("syncRecordValues", {
requests: [
{
id: id,
table: "block",
version: -1
}
]
const {recordMap} = await call("loadPageChunk", {
pageId: id,
limit: 100,
cursor: {
stack: [
[
{
table: "block",
id: id,
index: 0
}
]
]
},
chunkNumber: 0,
verticalColumns: false
});

const collectionBlock = pageData.recordMap.block[id].value;
const collectionBlock = recordMap.block[id].value;

if(!collectionBlock) {
return res.json({
Expand All @@ -38,18 +46,7 @@ module.exports = async (req, res) => {
})
}

const collectionId = collectionBlock.collection_id
const collectionViewId = collectionBlock.view_ids[0]

const tableData = await call("queryCollection", {
collectionId,
collectionViewId,
loader: {
type: "table"
}
});

const descriptionArray = tableData.recordMap.collection[collectionId].value.description;
const descriptionArray = recordMap.collection[collectionBlock.collection_id].value.description;

res.send(textArrayToHtml(descriptionArray))
}

1 comment on commit b6357ad

@vercel
Copy link

@vercel vercel bot commented on b6357ad Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.