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

Category Controller #7

Closed
28 tasks done
ChoaibMouhrach opened this issue Mar 23, 2023 · 1 comment · Fixed by #11
Closed
28 tasks done

Category Controller #7

ChoaibMouhrach opened this issue Mar 23, 2023 · 1 comment · Fixed by #11
Assignees
Labels
server-side This issue is related to server side

Comments

@ChoaibMouhrach
Copy link
Owner

ChoaibMouhrach commented Mar 23, 2023

  • index

    • Search
      • id
      • by name
    • Sort
      • id
      • name
    • Order
      • desc
      • inc
    • Fields
      • id
      • image
      • name
  • store

    • image
    • name
  • update

    • image
    • name
  • destroy

  • Testing

    • index
      • sort
      • fields
    • store
    • update
    • delete
@ChoaibMouhrach ChoaibMouhrach added the server-side This issue is related to server side label Mar 23, 2023
@ChoaibMouhrach ChoaibMouhrach pinned this issue Mar 30, 2023
@ChoaibMouhrach ChoaibMouhrach linked a pull request Mar 31, 2023 that will close this issue
@ChoaibMouhrach ChoaibMouhrach unpinned this issue Mar 31, 2023
@ID-JA
Copy link
Contributor

ID-JA commented Mar 31, 2023

@PACY2

https://github.com/PACY2/eco/blob/d1edc0fa66598bec406970e99c381db1a3415462/server/controllers/categoryController.ts#L119
when an item is deleted from the database, it is permanently removed, which can be problematic if we need to recover it later. By implementing a soft delete feature, we can change the status of the deleted item to indicate that it has been deleted, but still keep the item in the database. This way, we can recover it if needed.

There are different ways to implement soft delete but one common approach is to add a deletedAt field to the database table. When an item is deleted, we would update the deletedAt field with the current timestamp, but the item would still exist in the database. Then, when querying the database, we would exclude items that have a non-null deletedAt value.

const categorySchema = new Schema({
  name: {
    type: String,
    required: true,
    unique: true,
    dropDups: true
  },
  image: String
+ deletedAt: { type: Date, default: null }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server-side This issue is related to server side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants