Class: UserDataAccess

UserDataAccess()

Class to handle user data access with localStorage. Provides methods for retrieving, adding, updating, and deleting user data.

Constructor

new UserDataAccess()

Initializes the UserDataAccess instance. Checks if the "userData" key exists 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.<{id: number, firstName: string, lastName: string, email: string}>}

Retrieves all users from localStorage.
Source:
Returns:
List of 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 if found, else null.
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 user's ID (automatically assigned).
firstName string The user's first name.
lastName string The user's last name.
email string The user's email address.
Source:

updateUser(updatedUser)

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