3.2 KiB
manifestattachment
This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.
manifestattachment.add
Source: src/store/manifestattachment/add.js
Attaches a file to an existing manifest.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
manifestId |
number |
The id of the manifest. |
input |
object |
The file data. |
input.mimetype |
string |
The MIME type of the file (e.g. 'application/pdf'). |
input.name |
string |
The file name. |
input.content |
Buffer |
The file content. |
Returns
Promise<{id: number, manifestId: number, fileId: number, mimetype: string, name: string}> — The created attachment record.
Throws
Error — If the manifest is not found or file input is invalid.
Example
const attachment = await store.manifestattachment.add(42, 1, {
mimetype: 'application/pdf',
name: 'invoice.pdf',
content: fileBuffer,
});
// => { id, manifestId, fileId, mimetype, name }
manifestattachment.getById
Source: src/store/manifestattachment/getById.js
Gets an attachment for a manifest by its attachment ID or file ID, including full file content.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
manifestId |
number |
The manifest ID. |
id |
number |
The attachment ID or file ID. |
Returns
Promise<{id: number, manifestId: number, fileId: number, mimetype: string, name: string, content: Buffer}> — The attachment record with binary content.
Throws
Error — If the manifest or attachment is not found, or user is not authorized.
Example
const attachment = await store.manifestattachment.getById(42, 1, 5);
// => { id, manifestId, fileId, mimetype, name, content }
manifestattachment.listByManifestId
Source: src/store/manifestattachment/listByManifestId.js
Lists all attachments for a given manifest, without loading their full binary content.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
manifestId |
number |
The manifest ID. |
Returns
Promise<Array<{id: number, manifestId: number, fileId: number, mimetype: string, name: string, size: number}>> — A list of attachment metadata objects.
Throws
Error — If the manifest is not found or the user is not authorized.
Example
const attachments = await store.manifestattachment.listByManifestId(42, 1);
// => [{ id, manifestId, fileId, mimetype, name, size }]
manifestattachment.remove
Source: src/store/manifestattachment/remove.js
Removes a file attachment from a manifest and deletes the underlying file.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
manifestId |
number |
The manifest ID. |
id |
number |
The attachment ID or file ID to remove. |
Returns
Promise<void>
Throws
Error — If the manifest or attachment is not found, or user is not authorized.
Example
await store.manifestattachment.remove(42, 1, 5);