# Class: UserDAO

## UserDAO

#### new UserDAO(db)

  Data access object for users.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `db` | Connection | instance of connection to data storage.

  Source:
    - app/model/dao/UserDAO.js, line 12

### Methods

#### find(userId, callback)

  Finds a User according to given userId. At the end, given callback is executed with the result of find as argument.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `userId` | Number |
  `callback` | Function |

  Source:
    - app/model/dao/UserDAO.js, line 70

#### findAll(callback)

  Finds all users.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | Function |

  Source:
    - app/model/dao/UserDAO.js, line 43

#### findByUsername(username, callback)

  Finds a User according to its username. At the end, given callback is executed with the result of find as argument.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `username` | String |
  `callback` | Function |

  Source:
    - app/model/dao/UserDAO.js, line 95

#### new(data) → {User}

  Creates new User entity with prefilled fields.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `data` | Object |

  Source:
    - app/model/dao/UserDAO.js, line 23

  ##### Returns:

  Type
    User

#### persist(user, callback)

  Persist given User to storage. Executes callback with the persisted User as parameter.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `user` | User |
  `callback` | Function |

  Source:
    - app/model/dao/UserDAO.js, line 120