BuildShipBBuildShip
Powered by
solS
BuildShip•3y ago
sol

I'm going to suggest a solution to my own problem here, which is to modify the Create Document node

I'm going to suggest a solution to my own problem here, which is to modify the Create Document node and add a new docRef param, with the following code:

// Convert specified keys in data to document references based on docRefs object
    if (docRefs && typeof docRefs === 'object') {
        Object.keys(docRefs).forEach(refKey => {
            const refValue = data[refKey];
            if (refValue !== null && typeof refValue === 'string' && refValue !== '' && refValue !== 'null') {
                // Use the value in docRefs to determine the collection for the document reference
                data[refKey] = firestore.doc(
// Convert specified keys in data to document references based on docRefs object
    if (docRefs && typeof docRefs === 'object') {
        Object.keys(docRefs).forEach(refKey => {
            const refValue = data[refKey];
            if (refValue !== null && typeof refValue === 'string' && refValue !== '' && refValue !== 'null') {
                // Use the value in docRefs to determine the collection for the document reference
                data[refKey] = firestore.doc(
/${docRefs[refKey]}/${refValue}
);
            } else {
              // if the docref was passed but is empty, remove it to avoid an invalid ref
              delete data[refKey];
            }  
        });
    }
);
            } else {
              // if the docref was passed but is empty, remove it to avoid an invalid ref
              delete data[refKey];
            }  
        });
    }


That said, this seems like it should have built-in support in BuildShip as I'd imagine that DocumentReference is commonly used.
BuildShip banner
BuildShipJoin
Join founders, builders, devs using Low-code / No-code to create backend, APIs, scheduled Jobs, automation, AI workflows
8,040Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?
Next page

Similar Threads

A B D U L M A L I K - Hello, I’m new here.I’m ...
Answer OverflowAAnswer Overflow / šŸ’¬ćƒ»general
2mo ago
SVH - I feel really dumb here. I'm trying to i...
SVHSSVH / šŸ’¬ćƒ»general
16mo ago