implement global update

This commit is contained in:
Elliot DeNolf
2020-09-13 08:40:28 -04:00
parent 2b81e887ad
commit f2f8ffbbb2
2 changed files with 34 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);