patchFile(filePath, patchData) Last updated: 15. May 2025

API only function

Updates/patches an existing file in Docly document according to specified schema. The patch is merged with existing data.

Parameters

Name Type Description
filePath string Absolute path to where you want to patch data.
patchData object Data to patch into existing data. Properties specified here will overwrite existing properties in the file.

Returns

An object with references to the saved file with:
- timestamp
- guid
- filename

* Filename may be needed if autogenerated filenames are used.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// This shows the target file data before update
let targetFileDataBeforePatch = {
    "field1" : "old value 1",
    "field2" : "old value 2",
};

// When running this code:
let patch = { "field1" : "new value 1"};
docly.patchFile(targetFile, patch);

// The target file will look like this:
let targetFileDataAfterPatch = {
    "field1" : "new value 1", // This has been updated
    "field2" : "old value 2", // This remains unchanged
};