Removing use of the arguments[0] as they don't mesh well with TS.
This commit is contained in:
parent
b25033cab6
commit
5462ca5930
|
@ -9,7 +9,7 @@
|
|||
"url": "https://github.com/Budibase/budibase.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc && mv dist/src/* dist/ && rmdir dist/src/",
|
||||
"build": "rm -r dist/ && tsc && mv dist/src/* dist/ && rmdir dist/src/",
|
||||
"test": "jest --coverage --maxWorkers=2",
|
||||
"test:watch": "jest --watch",
|
||||
"build:docker": "docker build . -t app-service",
|
||||
|
|
|
@ -87,33 +87,34 @@ async function getFullLinkedDocs(appId, links) {
|
|||
|
||||
/**
|
||||
* Update link documents for a row or table - this is to be called by the API controller when a change is occurring.
|
||||
* @param {string} eventType states what type of change which is occurring, means this can be expanded upon in the
|
||||
* @param {string} args.eventType states what type of change which is occurring, means this can be expanded upon in the
|
||||
* future quite easily (all updates go through one function).
|
||||
* @param {string} appId The ID of the instance in which the change is occurring.
|
||||
* @param {string} tableId The ID of the of the table which is being changed.
|
||||
* @param {object|null} row The row which is changing, e.g. created, updated or deleted.
|
||||
* @param {object|null} table If the table has already been retrieved this can be used to reduce database gets.
|
||||
* @param {object|null} oldTable If the table is being updated then the old table can be provided for differencing.
|
||||
* @param {string} args.appId The ID of the instance in which the change is occurring.
|
||||
* @param {string} args.tableId The ID of the of the table which is being changed.
|
||||
* @param {object|null} args.row The row which is changing, e.g. created, updated or deleted.
|
||||
* @param {object|null} args.table If the table has already been retrieved this can be used to reduce database gets.
|
||||
* @param {object|null} args.oldTable If the table is being updated then the old table can be provided for differencing.
|
||||
* @returns {Promise<object>} When the update is complete this will respond successfully. Returns the row for
|
||||
* row operations and the table for table operations.
|
||||
*/
|
||||
exports.updateLinks = async function ({
|
||||
eventType,
|
||||
appId,
|
||||
row,
|
||||
tableId,
|
||||
table,
|
||||
oldTable,
|
||||
}) {
|
||||
exports.updateLinks = async function (args) {
|
||||
const {
|
||||
eventType,
|
||||
appId,
|
||||
row,
|
||||
tableId,
|
||||
table,
|
||||
oldTable,
|
||||
} = args
|
||||
const baseReturnObj = row == null ? table : row
|
||||
if (appId == null) {
|
||||
throw "Cannot operate without an instance ID."
|
||||
}
|
||||
// make sure table ID is set
|
||||
if (tableId == null && table != null) {
|
||||
arguments[0].tableId = table._id
|
||||
args.tableId = table._id
|
||||
}
|
||||
let linkController = new LinkController(arguments[0])
|
||||
let linkController = new LinkController(args)
|
||||
try {
|
||||
if (
|
||||
!(await linkController.doesTableHaveLinkedFields()) &&
|
||||
|
|
|
@ -17,24 +17,25 @@ exports.createLinkView = createLinkView
|
|||
|
||||
/**
|
||||
* Gets the linking documents, not the linked documents themselves.
|
||||
* @param {string} appId The instance in which we are searching for linked rows.
|
||||
* @param {string} tableId The table which we are searching for linked rows against.
|
||||
* @param {string|null} fieldName The name of column/field which is being altered, only looking for
|
||||
* @param {string} args.appId The instance in which we are searching for linked rows.
|
||||
* @param {string} args.tableId The table which we are searching for linked rows against.
|
||||
* @param {string|null} args.fieldName The name of column/field which is being altered, only looking for
|
||||
* linking documents that are related to it. If this is not specified then the table level will be assumed.
|
||||
* @param {string|null} rowId The ID of the row which we want to find linking documents for -
|
||||
* @param {string|null} args.rowId The ID of the row which we want to find linking documents for -
|
||||
* if this is not specified then it will assume table or field level depending on whether the
|
||||
* field name has been specified.
|
||||
* @param {boolean|null} includeDocs whether to include docs in the response call, this is considerably slower so only
|
||||
* @param {boolean|null} args.includeDocs whether to include docs in the response call, this is considerably slower so only
|
||||
* use this if actually interested in the docs themselves.
|
||||
* @returns {Promise<object[]>} This will return an array of the linking documents that were found
|
||||
* (if any).
|
||||
*/
|
||||
exports.getLinkDocuments = async function ({
|
||||
appId,
|
||||
tableId,
|
||||
rowId,
|
||||
includeDocs,
|
||||
}) {
|
||||
exports.getLinkDocuments = async function (args) {
|
||||
const {
|
||||
appId,
|
||||
tableId,
|
||||
rowId,
|
||||
includeDocs,
|
||||
} = args
|
||||
const db = new CouchDB(appId)
|
||||
let params
|
||||
if (rowId != null) {
|
||||
|
|
Loading…
Reference in New Issue