I’m trying to write a UDF as:
function function_delete_transaction(transaction_id, transfer_deleted) {
let transaction = Collection("collection_transactions").byId(transaction_id)
let transaction_account = transaction.account // document reference
let transaction_user = transaction.user // document reference
/*
transaction.transfer is a document reference, but it would only exist
if the transaction type was 'transfer' (that is, transferred from one
account to another).
*/
if (transaction.transfer != null && transfer_deleted != true) {
function_delete_transaction(transaction.transfer.id, true)
}
transaction_account.updateData({
balance: transaction_account.balance - transaction.amount,
transaction_count: transaction_account.transaction_count - 1
})
transaction_user.updateData({
net_worth: transaction_user.net_worth - transaction.amount,
transaction_count: transaction_user.transaction_count - 1
})
transaction.delete()
}
I get an error saying “Error updating schema” with the following details:
Error: Invalid database schema update.
error: Recursively defined `function_delete_transaction` needs explicit type.
at *function_delete_transaction.body*:1:1
|
1 | (transaction_id, transfer_deleted) => {
| _^
I believe the return type here would be null
as that’s what .delete()
returns for a document. But, how do I specify that type for the function to get rid of this error?