Skip to content
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

[Feature] Active, Archived and Soft Deleted records #6909

Open
evereq opened this issue Sep 29, 2023 · 2 comments · Fixed by #6923 or #6931
Open

[Feature] Active, Archived and Soft Deleted records #6909

evereq opened this issue Sep 29, 2023 · 2 comments · Fixed by #6923 or #6931
Assignees
Labels
Milestone

Comments

@evereq
Copy link
Member

evereq commented Sep 29, 2023

I think actually most of our entities should have the following standard fields:

  1. isActive - when we want to temporarily make some record not active and not be returned by most of the queries, metrics/reports, or disallow login of certain users, etc.

  2. isDeleted - when someone removed some record (but we need to keep it for Audit purposes or even for some past periods accounting, etc.) Note: for now we will use the "standard" deletedAt field in TypeORM used for Soft Delete feature, see https://typeorm.io/delete-query-builder#soft-delete

  3. isArchived - when something becomes not important anymore and can be archived, e.g. created 3 years ago some expense record.

@evereq evereq added the type: enhancement ✨ New feature or request label Sep 29, 2023
@evereq evereq added this to the v0.5 milestone Sep 29, 2023
@rahul-rocket
Copy link
Collaborator

@Gramosx So for this feature, We will have to add above columns into BaseEntity file. See below example.

export abstract class BaseEntity extends Model implements IBaseEntityModel {
	@ApiPropertyOptional({ type: () => String })
	@PrimaryGeneratedColumn('uuid')
	id?: string;

	// When record was created in our DB
	@ApiProperty({
		type: 'string',
		format: 'date-time',
		example: '2018-11-21T06:20:32.232Z',
	})
	@CreateDateColumn()
	createdAt?: Date;

	// When record was updated in our DB
	@ApiProperty({
		type: 'string',
		format: 'date-time',
		example: '2018-11-21T06:20:32.232Z',
	})
	@UpdateDateColumn()
	updatedAt?: Date;

	// Indicates if record is active now
	@ApiPropertyOptional({ type: Boolean, default: true })
	@Column({ nullable: false, default: true })
	isActive: boolean;

	// Indicate if record is archived
	@ApiPropertyOptional({ type: Boolean, default: false })
	@Column({ nullable: false, default: false })
	isArchived: boolean;
}

Note: This could be a complex task, so please let me know if you will have any issues or concern about this feature.

@rahul-rocket
Copy link
Collaborator

@Gramosx Just for reference https://wanago.io/2021/10/25/api-nestjs-soft-deletes-postgresql-typeorm/

@Gramosx Gramosx linked a pull request Oct 3, 2023 that will close this issue
2 tasks
@Gramosx Gramosx reopened this Oct 4, 2023
@Gramosx Gramosx linked a pull request Oct 4, 2023 that will close this issue
2 tasks
rahul-rocket added a commit that referenced this issue Oct 30, 2023
@rahul-rocket rahul-rocket reopened this Nov 1, 2023
@ever-github ever-github bot added the Gauzy label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants