newOS for Developers
Back to Mood Management
Attach Post
beginnerAdd content (posts, images, files) to a mood
PUT /mood/attach/postOverview
The attachToFolder action links an existing post to a mood (folder). This creates an edge relationship in the graph database, making the post accessible within that folder's context.
Multiple attachment methods exist: single post, multiple posts, and progressive handlers for batch operations with progress tracking.
Request
import {
attachToFolder,
attachToFolders,
massAttachToFolder
} from "newgraph-signals/actions/folder";
// Attach single post to single folder
await attachToFolder(post, folder);
// Attach single post to multiple folders
await attachToFolders(post, [folder1, folder2]);
// Attach multiple posts to single folder
await massAttachToFolder([post1, post2], folder);
// Progressive handler for UI progress tracking
import { attachToFolderProgressive } from "newgraph-signals/actions/folder";
const progress = attachToFolderProgressive();
progress.exec({
id: "folder-uuid", // Target folder
targetId: "post-uuid", // Post to attach
label: "post" // "post" | "mood" | "user"
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Target folder/mood ID |
| targetId | string | Yes | ID of entity to attach |
| label | string | Yes | "post" | "mood" | "user" |
API Methods
| Label | API Endpoint | Description |
|---|---|---|
| post | PUT /mood/attach/post | Attach a post to a mood |
| mood | PUT /mood/attach/mood | Nest a mood inside another |
| user | PUT /mood/attach/user | Associate a user with a mood |
Cache Edge Pattern
// Edge created on attachment
{
from: "folder-id",
fromLabel: "folder",
to: "post-id",
toLabel: "post",
label: "attachment"
}
// Query pattern for retrieving folder posts
cache.__EDGES
.where("__outE")
.startsWith(`folder+${folderId}+attachment+post`)Edge Cases
Duplicate Attachments: Attaching the same post twice is idempotent - it won't create duplicate edges.
Cross-Folder: A single post can be attached to multiple folders simultaneously.
Cache Sync: The edge is stored via
cachePostAttachment()which uses delayed edge storage for batching.