Code Monkey home page Code Monkey logo

Comments (2)

danivek avatar danivek commented on August 17, 2024

Hi @mcmillhj-wta,

There is an example for custom schema in the Usage section on the Readme (see https://github.com/danivek/json-api-serializer#register-1). It uses a custom schema only-body for the comment resource.

Even if you use the custom schema feature, you will not be able to do what you expected. You must either transform your input data or transform the serialized output before sending it.

Why not transform your input data to this before serialize ? (have a property items wich is an array):

{
  "id": "c82452b7-c3c3-5551-8bef-22a73f9793bb",
    ....
  items: ["cc19857c-01eb-5c57-b730-be1a05ec54e9"]
}

with this configuration:

Serializer.register('alerts', {
  relationships: {
    items: {
      type: 'articles'
    }
  }
});

Serializer.register('articles', {});

from json-api-serializer.

mcmillhj-wta avatar mcmillhj-wta commented on August 17, 2024

@danivek Thank you, this was super helpful and I now have it worked as desired.

from json-api-serializer.

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.