Delete

Overview

The delete script is used to remove entries from a local JSON database. It reads a schema definition from dbdata.json, validates the provided data against the schema, and then removes the matching entry from the corresponding JSON file in the db directory.It takes the value entered by you in the function and compares it to the value of the first field of all the entries , hence the only the first matching entry is removed.

Usage

const { deleteEntry } = require('../helpers/delete');

// Delete a user with ID '3'
deleteEntry('User', { id: '3' });

// Delete a post with ID '3'
deleteEntry('Post', { id: '3' });
Table of Contents