Git Product home page Git Product logo

Comments (2)

leplatrem avatar leplatrem commented on June 3, 2024

Currently we only implemented this behavior on the default_bucket plugin, which has a lot of other specificities.

One possibility is to use the concurrency control requests headers in your client, to create only if it doesn't exist.

$ http PUT https://kinto.dev.mozaws.net/v1/buckets/a "If-None-Match: *" -a user:pass
HTTP/1.1 201 Created
Access-Control-Expose-Headers: Alert, Content-Length, Backoff, Retry-After, Content-Type
Connection: keep-alive
Content-Length: 152
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none';
Content-Type: application/json
Date: Wed, 10 Nov 2021 14:48:40 GMT
ETag: "1636555720093"
Last-Modified: Wed, 10 Nov 2021 14:48:40 GMT
Server: nginx
X-Content-Type-Options: nosniff

{
    "data": {
        "id": "a",
        "last_modified": 1636555720093
    },
    "permissions": {
        "write": [
            "basicauth:631c2d625ee5726172cf67c6750de10a3e1a04bcd603bc9ad6d6b196fa8257a6"
        ]
    }
}

If it exists it will return 412 (that your client code can ignore on purpose)

$ http PUT https://kinto.dev.mozaws.net/v1/buckets/a "If-None-Match: *" -a user:pass
HTTP/1.1 412 Precondition Failed
Access-Control-Expose-Headers: Alert, Content-Length, Backoff, Retry-After, Content-Type
Connection: keep-alive
Content-Length: 162
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none';
Content-Type: application/json
Date: Wed, 10 Nov 2021 14:48:42 GMT
ETag: "1636555720093"
Last-Modified: Wed, 10 Nov 2021 14:48:40 GMT
Server: nginx
X-Content-Type-Options: nosniff

{
    "code": 412,
    "details": {
        "existing": {
            "id": "a",
            "last_modified": 1636555720093
        }
    },
    "errno": 114,
    "error": "Precondition Failed",
    "message": "Resource was modified meanwhile"
}

from kinto.

slav0nic avatar slav0nic commented on June 3, 2024

also you can manually create empty collection based on notification on backend level.
For example: create profile collection when new account created.

from kinto.

Related Issues (20)

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.