diff --git a/src/globals/operations/local/update.js b/src/globals/operations/local/update.js index e69de29bb2..a287eef9d7 100644 --- a/src/globals/operations/local/update.js +++ b/src/globals/operations/local/update.js @@ -0,0 +1,27 @@ +async function update(options) { + const { + global: globalSlug, + depth, + locale, + fallbackLocale, + data, + } = options; + + const globalConfig = this.globals.config.find((config) => config.slug === globalSlug); + + return this.operations.globals.update({ + slug: globalSlug, + data, + depth, + globalConfig, + overrideAccess: true, + req: { + payloadAPI: 'local', + locale, + fallbackLocale, + payload: this, + }, + }); +} + +module.exports = update; diff --git a/src/index.js b/src/index.js index f9f88fd439..906bfedd7b 100644 --- a/src/index.js +++ b/src/index.js @@ -97,6 +97,7 @@ class Payload { this.create = this.create.bind(this); this.find = this.find.bind(this); this.findGlobal = this.findGlobal.bind(this); + this.updateGlobal = this.updateGlobal.bind(this); this.findByID = this.findByID.bind(this); this.update = this.update.bind(this); this.register = this.register.bind(this); @@ -136,6 +137,12 @@ class Payload { return findOne(options); } + async updateGlobal(options) { + let { update } = localGlobalOperations; + update = update.bind(this); + return update(options); + } + async findByID(options) { let { findByID } = localOperations; findByID = findByID.bind(this);