Deleting a record
Delete a single record from the API
Ensuring a clean and up-to-date database is crucial. While updates can modify records, there are occasions when you might need to remove them entirely. With Noloco's dynamic GraphQL API, the process of deleting records is both straightforward and efficient. This guide will explain how to delete a record using the API.
Delete an existing record with the API
To delete an existing record, you'll use a GraphQL mutation in the format mutation delete<tableName>
, where <tableName>
represents the name of the table containing the record you wish to remove.
Examples:
For deleting a project:
mutation deleteProjects
.For removing a user:
mutation deleteUser
.
Specifying the Record ID for Deletion
When it comes to deletion, the only required argument is the integer ID
of the record you're targeting. By specifying the ID
, you ensure that you're deleting the precise record you intend to.
Example:
In this example, the user with ID 123
is scheduled for deletion.
Requesting Return Fields After Deletion
Even though the record is being deleted, you can still request fields from that record in the deletion response. This allows you to confirm which record was removed, and any of its associated data. This feature is especially handy for logging purposes or to provide instant feedback to users or systems.
For instance:
After deletion, the response will provide details like id
, name
, and the lead
of the deleted project, ensuring you have a clear view of what has been removed.
Conclusion
Efficient data management often involves the removal of unnecessary or outdated records. Noloco's GraphQL API simplifies the deletion process, ensuring that you can maintain a streamlined and organized database. By using specific deletion mutations and having the option to view deleted record details, you can confidently manage your data lifecycle.
Last updated