@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 874 B
JavaScript
import{copy as e}from"../../libs/i18n/copy.mjs";import t from"../../libs/repositories/user-tenants.mjs";import{getTenantConfig as n}from"../../utils/helpers/tenants.mjs";const r=async(r,i)=>{if(i.tenantKeys===void 0)return{error:void 0,data:void 0};let a=Array.from(new Set(i.tenantKeys)),o=a.find(e=>n(r.config,e)===void 0);if(o!==void 0)return{error:{type:`basic`,message:e(`server:core.tenants.unknown`,{data:{key:o}}),status:400},data:void 0};let s=new t(r.db.client,r.config.db),c=await s.deleteMultiple({where:[{key:`user_id`,operator:`=`,value:i.userId}],returning:[`id`],validation:{enabled:!0}});if(c.error)return c;if(a.length===0)return{error:void 0,data:void 0};let l=await s.createMultiple({data:a.map(e=>({user_id:i.userId,tenant_key:e}))});return l.error?l:{error:void 0,data:void 0}};export{r as default};
//# sourceMappingURL=update-multiple-tenants.mjs.map