1
0
Fork 0
mirror of synced 2024-06-16 09:25:12 +12:00
budibase/packages/server/middleware/controllers/application.js

21 lines
560 B
JavaScript
Raw Normal View History

2020-04-08 04:25:09 +12:00
const couchdb = require("../../db");
2020-04-10 03:53:48 +12:00
exports.fetch = async function(ctx) {
const clientDb = couchdb.db.use(`client-${ctx.params.clientId}`);
const body = await clientDb.view("client", "by_type", {
include_docs: true,
key: ["app"]
});
2020-04-09 03:57:27 +12:00
2020-04-10 03:53:48 +12:00
ctx.body = body.rows;
};
2020-04-08 04:25:09 +12:00
2020-04-10 03:53:48 +12:00
exports.create = async function(ctx) {
const clientDb = couchdb.db.use(`client-${ctx.params.clientId}`);
const { id, rev } = await clientDb.insert(ctx.request.body)
ctx.body = {
id,
rev,
message: `Application ${ctx.request.body.name} created successfully`
}
};