Does delete operation on a table's record actually delete it?


The table contained a few entries but eventually, I removed them and made it empty. Then I tried to add a new mandatory field but without success because of the message on the screenshot. I’ve set the initial value to work around that, but a question emerged in my head, doesn’t it mean that the data actually was not deleted from the table and that’s why I see that message? If yes then for which reason? Can I restore it somehow?

Hey @eddig - there are delete and destroy operations on the API. Destroy is a permanent deletion and Delete is a soft delete.

If you want to query a list of deleted records, you can do so like this:

query {
  tableASList(withDeleted: true) {
    items {
      id
      deletedAt
    }
  }
}

and the response would look like this

{
  "data": {
    "tableASList": {
      "items": [
        {
          "id": "ckdop5xm000ce08ky64ya44dt",
          "deletedAt": 0
        },
        {
          "id": "ckdop60lg00ct08ky6ohs03tw",
          "deletedAt": 0
        },
        {
          "id": "ckdop65e100j007l2akcscmvl",
          "deletedAt": 1597075477
        }
      ]
    }
  }
}

Records “deleted” are marked with a timestamp signifying the time at which they got deleted. The record could then be restored like so:

mutation {
  tableARestore(id: "ckdop65e100j007l2akcscmvl") {
    id
  }
}

or Destroyed like so permanently:

mutation {
  tableADestroy(filter: {
    id: "ckdop65e100j007l2akcscmvl"
  },
  force: true) {
    success
  }
}

Specifying force: true would ALSO destroy dependent records.

Hope this helps!

1 Like

Thanks @sebastian.scholl, it helped a lot. Now I better understand what is happening :slight_smile:

1 Like