1
0
Fork 0
mirror of synced 2024-06-26 10:00:41 +12:00

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 184936217c
commit c9ab2c4fcb
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)
}