1
0
Fork 0
mirror of synced 2024-09-21 20:01:32 +12:00
budibase/packages/frontend-core/src/api/viewsV2.js

30 lines
728 B
JavaScript
Raw Normal View History

2023-07-19 20:15:05 +12:00
export const buildViewV2Endpoints = API => ({
/**
2023-07-20 03:18:29 +12:00
* Create a new view
* @param tableId the id of the table where the view will be created
* @param view the view object
2023-07-19 20:15:05 +12:00
*/
2023-07-20 09:06:08 +12:00
create: async view => {
2023-07-20 03:18:29 +12:00
return await API.post({
2023-07-20 09:06:08 +12:00
url: `/api/v2/views`,
2023-07-20 03:18:29 +12:00
body: view,
})
2023-07-19 20:15:05 +12:00
},
/**
2023-07-20 03:18:29 +12:00
* Fetches all rows in a view
* @param tableId the id of the table
* @param viewId the id of the view
2023-07-19 20:15:05 +12:00
*/
2023-07-20 09:06:08 +12:00
fetch: async viewId => {
return await API.get({ url: `/api/v2/views/${viewId}/search` })
2023-07-19 20:15:05 +12:00
},
2023-07-19 22:20:19 +12:00
/**
* Delete a view
2023-07-20 03:18:29 +12:00
* @param tableId the id of the table
* @param viewId the id of the view
2023-07-19 22:20:19 +12:00
*/
2023-07-20 09:07:40 +12:00
delete: async viewId => {
return await API.delete({ url: `/api/v2/views/${viewId}` })
2023-07-19 22:20:19 +12:00
},
2023-07-19 20:15:05 +12:00
})