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
|
- Source:
updateUser(updatedUser)
Updates an existing user in localStorage.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
updatedUser |
Object | The updated user object.
Properties
|
- Source: