Skip to content

Commit

Permalink
add more funcitons
Browse files Browse the repository at this point in the history
  • Loading branch information
r350178982 committed Dec 19, 2023
1 parent 94cd200 commit 1cfde00
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,34 @@ class Base {
return this.req.get(url, {params});
}

getViewByName(table_name, view_name) {
const url = `api/v1/dtables/${this.dtableUuid}/views/${view_name}/?table_name=` + table_name;
return this.req.get(url)
}

addView(table_name, view_name) {
const url = `api/v1/dtables/${this.dtableUuid}/views/?table_name=` + table_name;
const data = {
name: view_name
};
return this.req.post(url, {...data});
}

renameView(table_name, view_name, new_view_name) {
const url = `api/v1/dtables/${this.dtableUuid}/views/${view_name}/?table_name=` + table_name;
const data = {
name: new_view_name,
}
return this.req.put(url, {...data});

}

deleteView(table_name, view_name) {
const url = `api/v1/dtables/${this.dtableUuid}/views/${view_name}/?table_name=` + table_name;
return this.req.delete(url);

}

listColumns(table_name, view_name) {
const url = `api/v1/dtables/${this.dtableUuid}/columns/`;
const params = {
Expand All @@ -135,6 +163,18 @@ class Base {
return this.req.get(url, {params});
}

async getColumnByName(table_name, column_name) {
const res = await this.listColumns(table_name);
return res.find(col=> col.name === column_name);

}

async getColumnsByType(table_name, column_type) {
const res = await this.listColumns(table_name);
return res.filter(col=> col.type === column_type);

}

insertColumn(table_name, column_name, column_type, column_key, column_data) {
const url = `api/v1/dtables/${this.dtableUuid}/columns/`;
const data = {
Expand Down

0 comments on commit 1cfde00

Please sign in to comment.