Git Product home page Git Product logo

Comments (3)

icebob avatar icebob commented on May 26, 2024 1

It's not totally clear to me. Could you start a draft PR to see your suggestions? I'm open to solving this problem

from database.

icebob avatar icebob commented on May 26, 2024

It depends on the use-case. In my projects, I use secure IDs, and I store the secure IDs as foreign keys.

By the way, Service A can't guarantee that it can encode the foreign key of IDs of Service B responses, because all services may use different encoding(e.g. hashids where the seed is based on service name).

If you don't want to return encoded IDs, use transform: false in options of action/method. But I'm looking forward your thoughts about how it can be improved to solve your use-case and the written use-cases as well.

from database.

saeedtabrizi avatar saeedtabrizi commented on May 26, 2024

Thankyou @icebob .
In my case I believe we must persist database Ids unsecure to separate database from app logic and operation, so we can query on database by aggregate or join operations with the same keys. this is benefit of my approach .
by the way .
Currently , I decided to write special action for resolve entities by unsecure ids . and change the field secure property to true and also I write a get and set method for foreign key fields to handle this issue temporary (workaround) .

...
labels: {
  type: "array",
  max: 100,
  secure:true,
  get:({value})=> value?.map((xx: string) => this.encodeID(xx)),
  set:({value})=> value?.map((xx: string) => this.decodeID(xx)),
  populate: "v1.labels.resolveUnSecureId"
}
app: {
   type: "string",
   columnName: "app_Id",
   immutable: true,
   optional: true ,
   secure: true,
  // eslint-disable-next-line object-shorthand
    set: function ({ value }) {return this.decodeID(value);},
		populate: "apps.resolveUnSecureId",
        },
...

In my case everything working good and OK .

But If we handle secure in foreign keys and have an option in resolveEntities method to enable/disable Id transformation , we can achieve a good experience and lower code writing.

from database.

Related Issues (10)

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.