Giter VIP home page Giter VIP logo

directus-extension-upsert's Introduction

Directus Extension upsert

As the name suggests a basic extension for upserting records in a single API call, it will check if the record exists and if so, update it, otherwise it will create it.

Tested with Directus 10

Installation

The package is published to npm: npm install directus-extension-upsert

Manual Installation

  • 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/hooks/directus-extension-upsert
  • Restart your Directus instance

Usages

This endpoint will intercept any POST requests to /upsert/:collection and check if the record exists and if so, update it, otherwise it will create it.

URL
  http://localhost:8055/upsert/:collection
Method
  POST
Headers
  Authorization: ...
  Content-Type: application/json
Body
{
    "filter": {
        "key": "test2"
    },
    "body": {
      "key": "test2",
      "value": "testindddddg"
    }
}

response

{
    "success": true,
    "msg": "Create Success",
    "code": 201,
    "data": null
}

or

{
    "success": true,
    "msg": "Update Success",
    "code": 201,
    "data": null
}

directus-extension-upsert's People

Contributors

freekrai avatar

Stargazers

jon ⚝ avatar Siro Díaz Palazón avatar Nikolai Novoselov avatar Glenn Layson avatar Chris Rault avatar James Ayers avatar Roman avatar

Watchers

 avatar  avatar

Forkers

atompi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.