Class: UserDataAccess

UserDataAccess()

A class that handles user data operations in the localStorage database.

Constructor

new UserDataAccess()

Initializes the UserDataAccess instance. Checks if 'userData' is already in localStorage. If not, initializes it with the dummy data.
Source:

Methods

deleteUser(id)

Deletes a user from the localStorage database by their ID.
Parameters:
Name Type Description
id number The ID of the user to delete.
Source:

getAllUsers() → {Array.<Object>}

Retrieves all users from the localStorage.
Source:
Returns:
List of all users in localStorage.
Type
Array.<Object>

getUserById(id) → {Object|null}

Retrieves a user by their unique ID.
Parameters:
Name Type Description
id number The ID of the user to retrieve.
Source:
Returns:
The user object if found, or null if not found.
Type
Object | null

insertUser(newUser)

Inserts a new user into the localStorage database.
Parameters:
Name Type Description
newUser Object The user object to insert.
Properties
Name Type Description
id number The ID of the new user.
firstName string The first name of the new user.
lastName string The last name of the new user.
email string The email address of the new user.
Source:

updateUser(updatedUser)

Updates an existing user's data in the localStorage database.
Parameters:
Name Type Description
updatedUser Object The user object with updated data.
Properties
Name Type Description
id number The ID of the user to update.
firstName string The updated first name of the user.
lastName string The updated last name of the user.
email string The updated email address of the user.
Source: