UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 924 B
import{copy as e}from"../../libs/i18n/copy.mjs";import t from"../../libs/repositories/options.mjs";const n=async(n,r)=>{let i=new t(n.db.client,n.config.db),a=await i.adjustInt({data:{name:r.name,delta:r.delta,max:r.max,min:r.min},validation:{enabled:!0}});if(a.error)return a;let o=Number(a.data.count);if(o===0&&r.ensure===!0){let e=await i.upsertSingle({data:{name:r.name,value_int:0,value_text:null,value_bool:null},returning:[`name`],validation:{enabled:!0}});if(e.error)return e;let t=await i.adjustInt({data:{name:r.name,delta:r.delta,max:r.max,min:r.min},validation:{enabled:!0}});return t.error?t:{error:void 0,data:{applied:Number(t.data.count)>0}}}return o===0?r.max===void 0||r.delta<=0?{error:{type:`basic`,message:e(`server:core.options.not.found.message`),status:404},data:void 0}:{error:void 0,data:{applied:!1}}:{error:void 0,data:{applied:!0}}};export{n as default}; //# sourceMappingURL=adjust-int.mjs.map