Coder Social home page Coder Social logo

Comments (5)

cojack avatar cojack commented on May 22, 2024

@geleto any example of use case?

from class-transformer.

geleto avatar geleto commented on May 22, 2024

I have a @RefById() transform decorator which rather than serializing the object - stores just the id of the object. When deserializing, the id is used to transparently set the reference to the existing object. Because of this, the transform does not need to be checked for circular references.

While I can use a getter/setter that does the id reference, this is not as clear and simple and my code would be littered with such getters/setters.

My implementation was probably a bit too complex, I modified a few things in class-transformer. One was disabling the circular checks. Another was supplying the parent object to transformFn - if the referenced object does not exist yet when deserializing, it would be assigned later when it is constructed, for which I needed to store the parent object.

Maybe what class-transformer actually needs is the ability to serialize/deserialize references to objects.

from class-transformer.

NoNameProvided avatar NoNameProvided commented on May 22, 2024

Hi @geleto!

You can control circular check via enableCircularCheck in the third parameter of classToPlain.

from class-transformer.

alexpls avatar alexpls commented on May 22, 2024

Hey @geleto, if your question's been answered by @NoNameProvided, would you mind closing this issue? Thanks!

from class-transformer.

github-actions avatar github-actions commented on May 22, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from class-transformer.

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.