Add fetch implementation for plugins and util for plugin params

This commit is contained in:
Andrew Kingston 2022-08-11 15:29:51 +01:00
parent f8324e4213
commit 14ffb78176
2 changed files with 17 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import { ObjectStoreBuckets } from "../../constants"
import { extractPluginTarball } from "../../utilities/fileSystem"
import { getGlobalDB } from "@budibase/backend-core/tenancy"
import { generatePluginID } from "../../db/utils"
import { generatePluginID, getPluginParams } from "../../db/utils"
import { uploadDirectory } from "@budibase/backend-core/objectStore"
export async function upload(ctx: any) {
@ -67,6 +67,14 @@ export async function upload(ctx: any) {
}
}
export async function fetch(ctx: any) {}
export async function fetch(ctx: any) {
const db = getGlobalDB()
const response = await db.allDocs(
getPluginParams(null, {
include_docs: true,
})
)
ctx.body = response.rows.map((row: any) => row.doc)
}
export async function destroy(ctx: any) {}

View File

@ -384,3 +384,10 @@ exports.getMultiIDParams = ids => {
include_docs: true,
}
}
/**
* Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
*/
exports.getPluginParams = (pluginId = null, otherProps = {}) => {
return getDocParams(DocumentTypes.PLUGIN, pluginId, otherProps)
}