Giter Site home page Giter Site logo

Bulk create to endpoints about safrs HOT 5 CLOSED

thomaxxl avatar thomaxxl commented on September 28, 2024
Bulk create to endpoints

from safrs.

Comments (5)

thomaxxl avatar thomaxxl commented on September 28, 2024

Hi,

I guess you want something like this: http://springbot.github.io/json-api/extensions/bulk/ ?
I just commited a change that implements this but it needs improvements: the POST works with
{data : [{..},{..}] } but the swagger isn't created and PATCH doesn't work.

from safrs.

wuzechen avatar wuzechen commented on September 28, 2024

Thanks for your reply.
There is another issue about bulk insert.
Follow the http://springbot.github.io/json-api/extensions/bulk/
Content-type of headers should be application/vnd.api+json; ext=bulk
If I try to use this header, it gives me a header error.
I fixed in safrs/request.py and safrs/jsonapi.py like this
safrs/request.py

class SAFRSRequest(Request):
-     jsonapi_content_types = ["application/json", "application/vnd.api+json"]
+     jsonapi_content_types = ["application/json", "application/vnd.api+json", "application/vnd.api+json; ext=bulk"]
+     jsonapi_content_bulk_types = ["application/vnd.api+json; ext=bulk"]
      is_jsonapi = False
+     is_bulk = False


    def __init__(self, *args, **kwargs):
        """
            constructor
        """
        super().__init__(*args, **kwargs)
        if self.content_type in self.jsonapi_content_types:
            self.is_jsonapi = True
            self.parameter_storage_class = TypeConversionDict
+       if self.content_type in self.jsonapi_content_bulk_types:
+          self.is_bulk = True
        self.parse_jsonapi_args()

safrs/jsonapi.py

         safrs.log.debug("method {} args {}".format(self.method_name, args))
-         if request.is_jsonapi:
+         if request.is_jsonapi and not request.is_bulk:
             args["self"] = instance
         result = method(**args)

from safrs.

thomaxxl avatar thomaxxl commented on September 28, 2024

ok, thanks
I'll implement it like that by next week.

from safrs.

thomaxxl avatar thomaxxl commented on September 28, 2024

I've committed support for bulk extension.

This still requires some improvement though.

from safrs.

thomaxxl avatar thomaxxl commented on September 28, 2024

v2.6.0 contains the bulk create functionality, it's undocumented for now.
Also, bulk patch doesn't work either.

from safrs.

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.