Directus (flagbit) icon

Directus (flagbit)

Consume Directus API

Utility → Sort Items

AI-generated

Overview

This node operation is designed to reorder items within a specified collection by moving a particular item to a new position relative to another item. It is useful in scenarios where the order of items matters, such as sorting tasks in a project management tool, rearranging products in an e-commerce catalog, or organizing entries in a list.

Use Case Examples

  1. Moving a task with primary key 16 to the position before the task with primary key 51 in a 'tasks' collection.
  2. Reordering a playlist by moving a song to a new position within the playlist collection.

Properties

Name Meaning
To Primary key of the item where the current item should be moved to, indicating the target position.
Item Primary key of the item that needs to be moved within the collection.
Collection Name Identifier of the collection containing the items to be sorted.

Output

JSON

  • movedItem - Details of the item that was moved after sorting.
  • updatedCollection - The collection state after the item has been reordered.

Dependencies

  • Requires access to the specified collection and the ability to modify item order within it.

Troubleshooting

  • Ensure the primary keys provided for 'Item' and 'To' exist in the specified collection; otherwise, the operation will fail.
  • Verify that the collection name is correct and accessible with the current credentials.
  • Common errors may include invalid item keys or permission issues when attempting to reorder items. Check API permissions and input values.

Discussion