Skip to content
Documentation
Load Method

Load YAML Method

The load method allows you to retrieve data from a specific data set (YAML file) within your verse.db database. It's a fundamental operation for accessing and managing your data. Here's how you can use it:

Syntax

const dataname = "users"; // Replace with the desired data name
const result = await db.load(dataname);
 
console.log(result.results);

Parameters

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

Return Value

Certainly! Let me describe how the results of the load method in the verse.db YAML adapter look like:

The load 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 load operation (e.g., "Data Loaded Successfully").
  • results: An array of objects representing the records within the loaded YAML file.

The results array contains individual objects, each representing a single record from the specified data set. These objects typically include key-value pairs corresponding to the fields and values within the data file.

For example, if you load data from a "users.yaml" file, the results might look like this:

{
  "acknowledged": true,
  "message": "Data Loaded Successfully",
  "results": [
    {
      "id": 1,
      "name": "John Doe",
      "age": 30,
      "email": "john@example.com"
    },
    {
      "id": 2,
      "name": "Alice Smith",
      "age": 28,
      "email": "alice@example.com"
    },
    // ... more user records
  ]
}

Each object within the results array corresponds to a user entry, with fields such as "id", "name", "age", and "email".

Example

In your provided example:

  • We load data from the "users.yaml" file.
  • The results object contains an array of objects, each representing a single record within the loaded YAML file.

Outcome

The load method efficiently retrieves data from your specified data set, allowing you to manage your data effectively within your verse.db project.


VERSE.DB. Powered by JEDI Studio.