mirror of https://github.com/Budibase/budibase.git
11 changed files with 96 additions and 3 deletions
@ -0,0 +1,18 @@ |
|||
const couchdb = require("../../db"); |
|||
|
|||
const controller = { |
|||
save: async ctx => { |
|||
}, |
|||
fetch: async ctx => { |
|||
const databaseId = ctx.params.databaseId; |
|||
const database = couchdb.db.use(databaseId) |
|||
ctx.body = await database.list({}); |
|||
}, |
|||
destroy: async ctx => { |
|||
const databaseId = ctx.params.databaseId; |
|||
const database = couchdb.db.use(databaseId) |
|||
ctx.body = await database.destroy(ctx.params.recordId); |
|||
}, |
|||
} |
|||
|
|||
module.exports = controller; |
|||
@ -0,0 +1,27 @@ |
|||
const couchdb = require("../../db"); |
|||
const fs = require("fs"); |
|||
|
|||
const controller = { |
|||
download: async ctx => { |
|||
// const appDatabase = couchdb.db.use(ctx.params.appId)
|
|||
// appDatabase.attachment.get('rabbit', 'rabbit.png', function(err, body) {
|
|||
// if (!err) {
|
|||
// fs.writeFile('rabbit.png', body);
|
|||
// }
|
|||
// });
|
|||
}, |
|||
upload: async ctx => { |
|||
// const appDatabase = couchdb.db.use(ctx.params.appId)
|
|||
// fs.readFile('rabbit.png', function(err, data) {
|
|||
// if (!err) {
|
|||
// alice.attachment.insert('rabbit', 'rabbit.png', data, 'image/png',
|
|||
// { rev: '12-150985a725ec88be471921a54ce91452' }, function(err, body) {
|
|||
// if (!err)
|
|||
// console.log(body);
|
|||
// });
|
|||
// }
|
|||
// });
|
|||
} |
|||
} |
|||
|
|||
module.exports = controller; |
|||
@ -0,0 +1,10 @@ |
|||
const Router = require("@koa/router"); |
|||
const controller = require("../../controllers/client"); |
|||
|
|||
const router = Router(); |
|||
|
|||
router |
|||
.post("/api/clients", controller.create) |
|||
.delete("/api/clients/:clientId", controller.destroy); |
|||
|
|||
module.exports = router; |
|||
@ -0,0 +1,11 @@ |
|||
const Router = require("@koa/router"); |
|||
const controller = require("../../controllers/view"); |
|||
|
|||
const router = Router(); |
|||
|
|||
router |
|||
.get("/api/:databaseId/views", controller.fetch) |
|||
.post("/api/:databaseId/views", controller.create) |
|||
.patch("/api/:databaseId/views", controller.update); |
|||
|
|||
module.exports = router; |
|||
Loading…
Reference in new issue