adds an init method to the tables store

This commit is contained in:
Keviin Åberg Kultalahti 2021-03-30 11:32:01 +02:00
parent e83cebde03
commit 7bb01a152c
2 changed files with 11 additions and 9 deletions

View File

@ -69,20 +69,14 @@ export const getFrontendStore = () => {
// Initialise backend stores // Initialise backend stores
const [ const [
_integrations, _integrations,
_tables,
] = await Promise.all([ ] = await Promise.all([
api.get("/api/integrations").then(r => r.json()), api.get("/api/integrations").then(r => r.json())
api.get(`/api/tables`).then(r => r.json()),
]) ])
datasources.init() datasources.init()
integrations.set(_integrations) integrations.set(_integrations)
queries.init() queries.init()
database.set(application.instance) database.set(application.instance)
tables.set({ tables.init()
list: _tables,
selected: {},
draft: {},
})
}, },
routing: { routing: {
fetch: async () => { fetch: async () => {

View File

@ -71,10 +71,18 @@ export function createTablesStore() {
return { return {
subscribe, subscribe,
set,
fetch, fetch,
select, select,
save, save,
init: async () => {
const response = await api.get("/api/tables")
const json = await response.json()
set({
list: json,
selected: {},
draft: {},
})
},
delete: async table => { delete: async table => {
await api.delete(`/api/tables/${table._id}/${table._rev}`) await api.delete(`/api/tables/${table._id}/${table._rev}`)
update(state => ({ update(state => ({