Class: UserDataAccess

UserDataAccess()

A class to manage user data in local storage. It allows retrieving, inserting, updating, and deleting users, as well as handling data persistence.

Constructor

new UserDataAccess()

Initializes the UserDataAccess class. It checks if user data exists in localStorage, and if not, it creates and populates it with the dummy data.
Source:

Methods

deleteUser(id)

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

getAllUsers() → {Array.<{id: number, firstName: string, lastName: string, email: string}>}

Retrieves all the users from localStorage.
Source:
Returns:
List of all users.
Type
Array.<{id: number, firstName: string, lastName: string, email: string}>

getUserById(id) → {Object|null}

Retrieves a user by their ID from localStorage.
Parameters:
Name Type Description
id number The ID of the user to retrieve.
Source:
Returns:
The user object, or null if no user is found with the provided ID.
Type
Object | null

insertUser(newUser)

Inserts a new user into localStorage. The new user will have a unique ID generated by the system.
Parameters:
Name Type Description
newUser Object The new user to insert.
Properties
Name Type Description
firstName string The first name of the new user.
lastName string The last name of the new user.
email string The email of the new user.
Source:

updateUser(updatedUser)

Updates an existing user in localStorage.
Parameters:
Name Type Description
updatedUser Object The updated user object.
Properties
Name Type Description
id number The ID of the user being updated.
firstName string The first name of the updated user.
lastName string The last name of the updated user.
email string The email of the updated user.
Source: