Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
867 B

const CouchDB = require("../../db");
const controller = {
fetch: async ctx => {
const db = new CouchDB(ctx.config)(ctx.params.instanceId);
const designDoc = await db.get("_design/database");
ctx.body = designDoc.views;
},
create: async ctx => {
const db = new CouchDB(ctx.config)(ctx.params.instanceId);
const { name, ...viewDefinition } = ctx.request.body;
const designDoc = await db.get("_design/database");
designDoc.views = {
...designDoc.views,
[name]: viewDefinition
};
const newView = await db.put(designDoc);
ctx.body = {
...newView,
message: `View ${name} created successfully.`,
status: 200,
}
},
destroy: async ctx => {
const db = new CouchDB(ctx.config)(ctx.params.instanceId);
ctx.body = await db.destroy(ctx.params.userId)
}
}
module.exports = controller;