Comments (3)
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.
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.
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)
- TypeError: Cannot read property 'eventType' of null HOT 1
- CreateEntity doens't handle _id ObjectId HOT 3
- Wrong check createActions HOT 5
- Default scope removed when scope query param provided though REST API
- MongoDB Adapter - InsertOne always failing in Mongo Community 4.4 HOT 4
- Populate nested fields HOT 1
- Race condition attack HOT 2
- Update major versions of dependencies
- [Question]: Is there any group by feature in database HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from database.