mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 02:24:16 +00:00
1.5 KiB
1.5 KiB
sidebar_position
sidebar_position |
---|
9 |
Update a post
Updates a post with the given post ID and update payload.
Only can update your own posts.
```js async function PostModel.update(post_id, payload) ```
[String] post_id
Defines the ID of the post to update.
[Object] Payload
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
message | String | false | undefined | The message of the post |
attachments | Array | true | [] | A list of attachments |
Success Response
Parameter | Type | Content |
---|---|---|
data | Object | post-object |
Examples
Basic usage
const post = await PostModel.update({
post_id: "0000",
message: "Updated message",
})
console.log(post)
// result: {
// _id_: "0000",
// message: "Updated message",
// timestamp: "2024-01-01T17:00:00.000Z",
// }
Modify or remove attachments
const post = await PostModel.update({
post_id: "0000",
attachments: [
{
url: "https://upload.wikimedia.org/wikipedia/commons/3/30/Vulpes_vulpes_ssp_fulvus.jpg",
}
],
})
console.log(post)
// result: {
// _id_: "0000",
// message: "Updated message",
// timestamp: "2024-01-01T17:00:00.000Z",
// attachments: [
// {
// url: "https://upload.wikimedia.org/wikipedia/commons/3/30/Vulpes_vulpes_ssp_fulvus.jpg",
// }
// ]
// }