Skip to content
Documentation
Drop Method

Drop YAML Method

The drop method is a powerful operation that allows you to remove an entire data set from your verse.db database. It's particularly useful when you want to delete all records associated with a specific data file. Here's how you can use it:

Syntax

const dataname = "users"; // Replace with the desired data name
const dropResult = await db.drop(dataname);

Parameters

  • dataname: The filename (without the .yaml extension) of the YAML file you want to drop. This name is also used when performing other operations like .add, .update, .remove, and .find on the corresponding data set.

Results

The drop method returns an object with the following properties:

  • acknowledged: A boolean indicating whether the operation was successful (true) or not (false).
  • message: A descriptive message indicating the outcome of the operation (e.g., "All data dropped successfully.").
  • results: An empty string (since no specific results are returned for the drop operation).
{
  "acknowledged": true,
  "message": `All data dropped successfully.`,
};

Description

  1. Arrange:

    • We start by defining a variable named dataname and assign it the value "users". This represents the name of the data set (YAML file) we want to drop.
    • Next, we call the db.drop(dataname) method to remove the entire data associated with the specified dataname.
  2. Results:

    • The drop method returns an object with the following properties:
      • acknowledged: A boolean indicating whether the operation was successful (true) or not (false).
      • message: A descriptive message indicating the outcome of the operation (e.g., "All data dropped successfully.").
      • results: An empty string (since no specific results are returned for the drop operation).

Outcome

The drop method effectively removes the data set named "users" from the database, and the result indicates successful execution.

By following these guidelines, you can manage your data efficiently within your verse.db project. If you have any further questions or need additional assistance, feel free to ask! 😊


VERSE.DB. Powered by JEDI Studio.