//directus-extension-randomizedbysandros94

directus-extension-randomized

An extension to get randomized results from directus.

0
0
0
TypeScript

Directus Extension Randomized Results

As the name suggests this extension will enable Randomized results mirroring the Directus /items/:collection endpoint.

Tested with Directus 10.6.3

Installation

The package is published to npm:
npm install directus-extension-randomized-endpoint

undefinedManual Installationundefined

  • Download or fork the repository
  • Install the requirements
    npm install
  • Build the extension
    npm run build
  • Move the result to your extension folder
    mv dist extensions/endpoints/directus-extension-randomized
  • Restart your Directus instance

Usages

Mirrors the REST version of this core endpoint supporting the same parameters https://docs.directus.io/reference/items.html#get-items

undefinedGET /randomized/test_collectionundefined

[
   { "id": 6, "status": "draft", "value": "369" },
   { "id": 2, "status": "published", "value": "456" },
   { "id": 4, "status": "published", "value": "147" },
   { "id": 3, "status": "published", "value": "789" },
   { "id": 5, "status": "draft", "value": "258" },
   { "id": 1, "status": "published", "value": "123" }
]
[
    {"id": 3, "status": "published", "value": "789"},
    {"id": 4, "status": "published", "value": "147"},
    {"id": 1, "status": "published", "value": "123"},
    {"id": 2, "status": "published", "value": "456"},
    {"id": 5, "status": "draft", "value": "258"},
    {"id": 6, "status": "draft", "value": "369"}
]

undefinedGET /randomized/test_collection?limit=2undefined

[
    {"id": 4, "status": "published", "value": "147"},
    {"id": 5, "status": "draft", "value": "258"}
]
[
    {"id": 2, "status": "published", "value": "456"},
    {"id": 4, "status": "published", "value": "147"}
]

undefinedGET /randomized/test_collection?limit=2&filter[status][_eq]=published&fields=value,statusundefined

[
    {"value": "456", "status": "published"},
    {"value": "147", "status": "published"}
]
[
    {"value": "789", "status": "published"},
    {"value": "147", "status": "published"}
]
[beta]v0.14.0