@directus/sdk
Version:
Directus JavaScript SDK
2 lines • 1.09 kB
JavaScript
const e=require(`../../utils/throw-if-empty.cjs`),t=require(`../../utils/throw-core-collection.cjs`),n=(n,r,i,a)=>()=>{let o={};return e.throwIfEmpty(String(n),`Collection cannot be empty`),t.throwIfCoreCollection(n,`Cannot use updateItems for core collections`),Array.isArray(r)?(e.throwIfEmpty(r,`keysOrQuery cannot be empty`),o={keys:r}):(e.throwIfEmpty(Object.keys(r),`keysOrQuery cannot be empty`),o={query:r}),o.data=i,{path:`/items/${n}`,params:a??{},body:JSON.stringify(o),method:`PATCH`}},r=(n,r,i)=>()=>(e.throwIfEmpty(String(n),`Collection cannot be empty`),t.throwIfCoreCollection(n,`Cannot use updateItems for core collections`),{path:`/items/${n}`,params:i??{},body:JSON.stringify(r),method:`PATCH`}),i=(n,r,i,a)=>()=>(e.throwIfEmpty(String(r),`Key cannot be empty`),e.throwIfEmpty(String(n),`Collection cannot be empty`),t.throwIfCoreCollection(n,`Cannot use updateItem for core collections`),{path:`/items/${n}/${r}`,params:a??{},body:JSON.stringify(i),method:`PATCH`});exports.updateItem=i,exports.updateItems=n,exports.updateItemsBatch=r;
//# sourceMappingURL=items.cjs.map