Merge branch 'linked-records' of github.com:Budibase/budibase into linked-records
This commit is contained in:
commit
eea35b6dfb
|
@ -128,14 +128,14 @@ describe("/automations", () => {
|
|||
it("should setup the automation fully", () => {
|
||||
let trigger = TRIGGER_DEFINITIONS["RECORD_SAVED"]
|
||||
trigger.id = "wadiawdo34"
|
||||
let saveAction = ACTION_DEFINITIONS["SAVE_RECORD"]
|
||||
saveAction.inputs.record = {
|
||||
let createAction = ACTION_DEFINITIONS["CREATE_RECORD"]
|
||||
createAction.inputs.record = {
|
||||
name: "{{trigger.name}}",
|
||||
description: "{{trigger.description}}"
|
||||
}
|
||||
saveAction.id = "awde444wk"
|
||||
createAction.id = "awde444wk"
|
||||
|
||||
TEST_AUTOMATION.definition.steps.push(saveAction)
|
||||
TEST_AUTOMATION.definition.steps.push(createAction)
|
||||
TEST_AUTOMATION.definition.trigger = trigger
|
||||
})
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const sendEmail = require("./steps/sendEmail")
|
||||
const saveRecord = require("./steps/saveRecord")
|
||||
const createRecord = require("./steps/createRecord")
|
||||
const updateRecord = require("./steps/updateRecord")
|
||||
const deleteRecord = require("./steps/deleteRecord")
|
||||
const createUser = require("./steps/createUser")
|
||||
|
@ -17,14 +17,14 @@ const DEFAULT_DIRECTORY = ".budibase-automations"
|
|||
const AUTOMATION_MANIFEST = "manifest.json"
|
||||
const BUILTIN_ACTIONS = {
|
||||
SEND_EMAIL: sendEmail.run,
|
||||
SAVE_RECORD: saveRecord.run,
|
||||
CREATE_RECORD: createRecord.run,
|
||||
UPDATE_RECORD: updateRecord.run,
|
||||
DELETE_RECORD: deleteRecord.run,
|
||||
CREATE_USER: createUser.run,
|
||||
}
|
||||
const BUILTIN_DEFINITIONS = {
|
||||
SEND_EMAIL: sendEmail.definition,
|
||||
SAVE_RECORD: saveRecord.definition,
|
||||
CREATE_RECORD: createRecord.definition,
|
||||
UPDATE_RECORD: updateRecord.definition,
|
||||
DELETE_RECORD: deleteRecord.definition,
|
||||
CREATE_USER: createUser.definition,
|
||||
|
|
|
@ -7,7 +7,7 @@ module.exports.definition = {
|
|||
icon: "ri-save-3-fill",
|
||||
description: "Add a row to your database",
|
||||
type: "ACTION",
|
||||
stepId: "SAVE_RECORD",
|
||||
stepId: "CREATE_RECORD",
|
||||
inputs: {},
|
||||
schema: {
|
||||
inputs: {
|
|
@ -55,7 +55,15 @@ module.exports.definition = {
|
|||
}
|
||||
|
||||
module.exports.run = async function filter({ inputs }) {
|
||||
const { field, condition, value } = inputs
|
||||
let { field, condition, value } = inputs
|
||||
// coerce types so that we can use them
|
||||
if (!isNaN(value) && !isNaN(field)) {
|
||||
value = parseFloat(value)
|
||||
field = parseFloat(field)
|
||||
} else if (!isNaN(Date.parse(value)) && !isNaN(Date.parse(field))) {
|
||||
value = Date.parse(value)
|
||||
field = Date.parse(field)
|
||||
}
|
||||
let success
|
||||
if (typeof field !== "object" && typeof value !== "object") {
|
||||
switch (condition) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const CouchDB = require("../index")
|
||||
const { IncludeDocs, getLinkDocuments } = require("./linkUtils")
|
||||
const { generateLinkID } = require("../utils")
|
||||
|
||||
/**
|
||||
* Creates a new link document structure which can be put to the database. It is important to
|
||||
|
@ -22,7 +23,7 @@ function LinkDocument(
|
|||
recordId2
|
||||
) {
|
||||
// build the ID out of unique references to this link document
|
||||
this._id = `${modelId1}/${modelId2}/${fieldName1}/${fieldName2}/${recordId1}/${recordId2}`
|
||||
this._id = generateLinkID(modelId1, modelId2, recordId1, recordId2)
|
||||
// required for referencing in view
|
||||
this.type = "link"
|
||||
this.doc1 = {
|
||||
|
|
Loading…
Reference in New Issue