Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

table.getAllViews()?

Topic Labels: Scripting extentions
425 1
cancel
Showing results for 
Search instead for 
Did you mean: 

I know there is getView(‘ViewName’) to retrieve a particuilar view of a table, but what if you don’t know the name of a view, or how many views there are?

Is there a way to fetch ALL the views of a given table? Something like this:

let table = base.getTable("TableName");
let allViews = table.getAllViews(); // something like this?
output.inspect(allViews);

I have a custom Vue app and want to display a table’s records and then populate a navbar with all the views so a user can click links to switch the table view.

1 Reply 1

Once you have a table, there is a views property for that table, which is an array of all views for the table. Here’s the code example from the docs:

// Show an interactive inspector for every view in "Borrower"
let table = base.getTable("Borrower");
for (let view of table.views) {
    output.inspect(view);
}