| 12345678910111213141516171819202122 |
- import { db } from '../utils/db'
- import { Profile } from '../entities/profile'
-
- /**
- * Get a single Profile from the database and
- * create a class from the data and
- * validate the incoming
- * @param {number} userId
- */
- const fetchProfilesByUserId = async userId => {
- const profilesForUserId = await db.get(`/user/${userId}/profiles`)
- const profileInstances = []
- profilesForUserId.map(profileData => {
- const profile = new Profile(profileData)
- if(profile.isValid()) {
- profileInstances.push(profile)
- }
- })
- return profileInstances
- }
-
- export { fetchProfilesByUserId }
|