What This Adds In Cloud Code
- Queue attachment processing for orders.
- Reset attachment download counters.
- Accepts either object drops or raw ids.
Quick Start
js
const OrderHelpers = require('order_helpers');
OrderHelpers.queueAttachmentProcessing(request.params.order_id);API
| Function | Params | Returns | Notes |
|---|---|---|---|
queue_attachment_processing(orderOrId) / queueAttachmentProcessing(...) | order object or id | boolean | Enqueues processing job for attachments. |
reset_attachment_download_count(orderOrId, attachmentOrId) / resetAttachmentDownloadCount(...) | order + attachment ref | boolean | Resets downloads left to default runtime value. |
Practical Example
js
const OrderHelpers = require('order_helpers');
Nimbu.Cloud.define('resetOrderAttachment', (request, response) => {
const ok = OrderHelpers.resetAttachmentDownloadCount(
request.params.order_id,
request.params.attachment_id
);
response.success({ ok });
});Failure Modes & Gotchas
- Invalid ids can cause falsey outcomes.
- Use this for order attachments only, not generic files.