-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serial (auto incremented) Id and deletedAt in BaseEntity #73
Comments
Serial IDs, though easy to start with, weren't built into hexapp as UUIDs (or the "new kids" GUID/CUID/NanoID) are much easier to work with in a distributed context. Serial IDs introduce an implicit dependency on the database to generate the primary key, whereas UUIDs can be generated on the server side without having to rely on the database. This is extremely useful in cases where you are generating multiple entities in a workflow where some entities refer to some other entities in a sequence of operations. With serial ids, you'd have to tie in the repository calls with the entity creation (as you cannot get the ID without the database call), whereas with UUIDs, you can generate the ID on the server and leave the persistence calls till the end (or even push them to the background job queue if required). This also makes working with third party APIs easier in cases where you want a set of records to be generated asynchronously without being tied to the request/response cycle, and persist the records only upon successful processing by the third party platform. Then we come to the At the end of the day, it's much easier to extend a minimal base for your use case than it is to make extra stuff mandatory and then keep having to remove it on a per-project basis. For both of the above discussed "enhancements", you can very easily create a base class in your project which extends |
I agree with your discussion of UUIDs. First, you mentioned that we can get server generated UUID. Of course, we can, but we are not doing it that way in any project at CT. Only Viral Solution's team is doing that. All other projects are doing db generated. So serial ID being a burden on db doesn't make the point. Also, UUID is still going to be our primary key that is being used inside the application as FKs and all the referencing and querying. Serial IDs will only be needed for data display. 2ndly, for the deletedAt, I totally disagree with your point. It is a necessary one. Considering the kind of projects we do here, they are all just fancy dashboards as you put it. For the user privacy problem, no one provides a hard delete on their dashboard. There is always a delete request method that is usually integrated into the system where users can make the ticket to get their data permanently deleted. Also, if we are going to permanently delete user data, it must say on the FE that you are permanently going to delete a certain data (which we are not doing anywhere unless asked from the client). Also, the problem with these kinds of frameworks that someone builds like .NET, Spring, is there are always changes in newer versions that are not available in the previous versions so they have to make a support timeline of specific versions so that you are maintaining the old version for the projects that depend on it for some time, (or maybe just freeze them) and new projects can still benefit from the added features in newer versions. It does not make sense to do something where you change something in your framework and all the previous projects implemented in that specific version have to change themselves also. So at the end of day, what matters is the business needs, and how we are going to fulfill it. Making the job a little bit easier on the development side goes a long way. I believe that is what the hexapp aims to solve. |
It is being done in all the projects I have worked on so far, and is one of the core parts of You can disagree with my point related to Also, not all projects, including the ones at Carbonteq, are glorified admin dashboards. Admin dashboard here refers to applications which provide a presentation layer and some custom logic related to the client's data directly, as opposed to a platform where users different from the client/stakeholders sign up, provide their data and benefit from a specific set of services. You can argue about which projects lie in which category, and by how much, but at the end of the day, projects in both of the categories have both kinds of entities, the ones that the client doesn't want to be hard deleted (perhaps a record of actions that might be required for an audit) and records that do need to be hard deleted (e.g. metadata for files related to a user). Keeping this in mind, consider the route where Business needs matter in a project where you're building a solution for said business, but I would advise against treating everything as a nail with this one hammer in hand. I have shared the solution to what you require for your project in my previous comment and this one again. Just a single class in your project which extends from Asides:
|
sId
that needs to be displayed on the front-end for user experience purposes and it is good to have this id for all our models.deletedAt
like createdAt and updatedAt, that will be just need to be updated by the current date while deleting and we can restore that row whenever we need by just setting the same column to null.Although, it will require additional work on developer side to make sure that while querying the data, is
mode.deletedAt IS NULL
filter is applied in where filter or not. Some ORMS like typeORM, Sequelize, Prisma provides auto check of deletedAt is null but for the case of drizzleORM, we'll have to manually check for the deletedAt column, but its a simple enough task.The text was updated successfully, but these errors were encountered: