Comments
Get Comments
Returns a list of comments.
Query Parameters
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
What metadata to return in the response.
How many items to skip when fetching data.
How to sort the returned items. sort
is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-
) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ?
to sort randomly.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Responses
Collection identifier in which the item resides.
Unique identifier for the object.
The item the comment is created for.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
Timestamp in ISO8601 when the comment was created.
Timestamp in ISO8601 when the comment was last updated.
The user who created the comment. Many-to-one to users.
The user who last updated the comment. Many-to-one to users.
Returns the total item count of the collection you're querying.
Returns the item count of the collection you're querying, taking the current filter/search parameters into account.
GET /comments
import { createDirectus, rest, readComments } from '@directus/sdk';
const client = createDirectus('directus_comment_example').with(rest());
const result = await client.request(readComments(query));
type Query {
flows: [directus_comments]
}
{
"data": [
{
"collection": "articles",
"id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
"item": 15,
"comment": "This is a comment on an article",
"date_created": "2023-01-15T09:14:52Z",
"date_updated": "2023-01-15T09:00:00Z",
"user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
"user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
}
],
"meta": {}
}
Create Multiple comments
Create multiple new comments. This action is only available to authenticated users.
Query Parameters
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
What metadata to return in the response.
How many items to skip when fetching data.
How to sort the returned items. sort
is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-
) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ?
to sort randomly.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Request Body
Collection identifier in which the item resides.
Unique identifier for the object.
The item the comment is created for.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
Timestamp in ISO8601 when the comment was created.
Timestamp in ISO8601 when the comment was last updated.
The user who created the comment. Many-to-one to users.
The user who last updated the comment. Many-to-one to users.
Responses
Collection identifier in which the item resides.
Unique identifier for the object.
The item the comment is created for.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
Timestamp in ISO8601 when the comment was created.
Timestamp in ISO8601 when the comment was last updated.
The user who created the comment. Many-to-one to users.
The user who last updated the comment. Many-to-one to users.
Returns the total item count of the collection you're querying.
Returns the item count of the collection you're querying, taking the current filter/search parameters into account.
POST /comments
import { createDirectus, rest, createComments } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(createComments(comments_object_array));
POST /graphql/system
type Mutation {
create_comments_items(data: [create_directus_comments_input!]!): [directus_comments]
}
{
"data": [
{
"collection": "articles",
"id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
"item": 15,
"comment": "This is a comment on an article",
"date_created": "2023-01-15T09:14:52Z",
"date_updated": "2023-01-15T09:00:00Z",
"user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
"user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
}
],
"meta": {}
}
Delete Multiple Comments
Delete multiple existing comments. This action is only available to authenticated users.
Responses
DELETE /comments
import { createDirectus, rest, deleteComments } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteComments(comment_id_array));
POST /graphql/system
type Mutation {
delete_Comments_items(ids: [ID!]!): delete_many
}
Update Multiple comments
Update multiple existing comments. This action is only available to authenticated users.
Query Parameters
Control what fields are being returned in the object.
A limit on the number of objects that are returned.
What metadata to return in the response.
How many items to skip when fetching data.
How to sort the returned items. sort
is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-
) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ?
to sort randomly.
Select items in collection by given conditions.
Filter by items that contain the given search query in one of their fields.
Request Body
Collection identifier in which the item resides.
Unique identifier for the object.
The item the comment is created for.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
Timestamp in ISO8601 when the comment was created.
Timestamp in ISO8601 when the comment was last updated.
The user who created the comment. Many-to-one to users.
The user who last updated the comment. Many-to-one to users.
Responses
Collection identifier in which the item resides.
Unique identifier for the object.
The item the comment is created for.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
Timestamp in ISO8601 when the comment was created.
Timestamp in ISO8601 when the comment was last updated.
The user who created the comment. Many-to-one to users.
The user who last updated the comment. Many-to-one to users.
Returns the total item count of the collection you're querying.
Returns the item count of the collection you're querying, taking the current filter/search parameters into account.
PATCH /comments
import { createDirectus, rest, updateComments } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateComments(comments_id_array, partial_comment_object));
POST /graphql/system
type Mutation {
update_comments_items(ids: [ID!]!, data: update_directus_comments_input): [directus_comments]
}
{
"data": [
{
"collection": "articles",
"id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
"item": 15,
"comment": "This is a comment on an article",
"date_created": "2023-01-15T09:14:52Z",
"date_updated": "2023-01-15T09:00:00Z",
"user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
"user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
}
],
"meta": {}
}
Create a Comment
Creates a new comment.
Query Parameters
What metadata to return in the response.
Request Body
Responses
Unique identifier for the object.
Action that was performed.
The user who performed this action. Many-to-one to users.
When the action happened.
The IP address of the user at the time the action took place.
User agent string of the browser the user used when the action took place.
Collection identifier in which the item resides.
Unique identifier for the item the action applied to. This is always a string, even for integer primary keys.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the admin app.
Origin of the request when the action took place.
Any changes that were made in this activity. One-to-many to revisions.
POST /comments
import { createDirectus, rest, createComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(
createComment({
collection: collection_name,
item: item_id,
comment: comment_content,
})
);
POST /graphql/system
type Mutation {
create_comment(collection: String!, item: ID!, comment: String!): directus_activity
}
{
"data": {
"id": 2,
"action": "update",
"timestamp": "2019-12-05T22:52:09Z",
"ip": "127.0.0.1",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/78.0.3904.108 Safari/537.36",
"item": "328",
"comment": null,
"origin": "https://directus.io",
"revisions": []
}
}
Get Comment by ID
Returns a single comment by primary key.
Query Parameters
Identifier for the object.
Control what fields are being returned in the object.
What metadata to return in the response.
Responses
Collection identifier in which the item resides.
Unique identifier for the object.
The item the comment is created for.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
Timestamp in ISO8601 when the comment was created.
Timestamp in ISO8601 when the comment was last updated.
The user who created the comment. Many-to-one to users.
The user who last updated the comment. Many-to-one to users.
GET /comments/{id}
import { createDirectus, rest, readComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readComment(comment_id, query_object));
type Query {
comment_by_id(id: ID!): directus_comments
}
{
"data": {
"collection": "articles",
"id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
"item": 15,
"comment": "This is a comment on an article",
"date_created": "2023-01-15T09:14:52Z",
"date_updated": "2023-01-15T09:00:00Z",
"user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
"user_updated": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af"
}
}
Delete a Comment
Delete an existing comment. This action is only available to authenticated users.
Query Parameters
Identifier for the object.
Responses
DELETE /comments/{id}
import { createDirectus, rest, deleteComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteComment(comment_id));
POST /graphql/system
type Mutation {
delete_comment(id: ID): delete_one
}
Update a Comment
Update an existing comment. This action is only available to authenticated users.
Query Parameters
Identifier for the object.
What metadata to return in the response.
Request Body
Collection identifier in which the item resides.
Unique identifier for the object.
The item the comment is created for.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the Data Studio.
Timestamp in ISO8601 when the comment was created.
Timestamp in ISO8601 when the comment was last updated.
The user who created the comment. Many-to-one to users.
The user who last updated the comment. Many-to-one to users.
Responses
Unique identifier for the object.
Action that was performed.
The user who performed this action. Many-to-one to users.
When the action happened.
The IP address of the user at the time the action took place.
User agent string of the browser the user used when the action took place.
Collection identifier in which the item resides.
Unique identifier for the item the action applied to. This is always a string, even for integer primary keys.
User comment. This will store the comments that show up in the right sidebar of the item edit page in the admin app.
Origin of the request when the action took place.
Any changes that were made in this activity. One-to-many to revisions.
PATCH /comments/{id}
import { createDirectus, rest, updateComment } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateComment(comment_id, partial_comment_object));
POST /graphql/system
type Mutation {
update_comments_item(id: ID!, data: update_directus_comments_input): directus_comments
}
{
"data": {
"id": 2,
"action": "update",
"timestamp": "2019-12-05T22:52:09Z",
"ip": "127.0.0.1",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/78.0.3904.108 Safari/537.36",
"item": "328",
"comment": null,
"origin": "https://directus.io",
"revisions": []
}
}