Skip to content

Instantly share code, notes, and snippets.

@harryWonder
Created December 8, 2023 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save harryWonder/89bc1d08b92044f6d391c9228ae6c15d to your computer and use it in GitHub Desktop.
Save harryWonder/89bc1d08b92044f6d391c9228ae6c15d to your computer and use it in GitHub Desktop.
const PhotoEntity = require('../entity/photo.entity')
class PhotoDao {
/**
*
* @module Photo
* @description This method creates a new Photo instance and persists it to the database.
*
* @typedef {Object} Photo
* @property {string} id
* @property {string} face_id
* @property {string} image_id
* @property {string} filename
* @property {string} bvn_filename
* @property {number} duplicate_image
* @property {number} duplicate_image_count
* @property {string} duplicate_image_destination
* @property {number} upload_status
* @property {number} status
* @property {number} similarity
* @property {string} bvn
* @property {number} bvn_profile_similarity
* @property {number} image_processed
* @property {string} liveness
* @property {string} message
* @property {Date?} created_at
* @property {Date?} updated_at
*
* @param {Partial<Photo>} payload
* @returns {Promise<Photo>}
*
*/
async insert(payload) {
return await PhotoEntity.create(payload);
}
/**
*
* @param {Partial<Photo>} payload
* @param {Partial<Photo>} condition
*
* @alias module:Photo.Photo
*
*/
async update(payload, condition) {
return await PhotoEntity.update(payload, { where: condition });
}
/**
*
* @param {Partial<Photo>} payload
* @alias module:Photo.Photo
*
*/
async findOne(payload) {
return await PhotoEntity.findOne({ where: payload });
}
/**
*
* @param {Partial<Photo>} attributes
* @param {Partial<Photo>} payload
*
* @alias module:Photo.Photo
*
*/
async findAll(attributes, payload) {
return await PhotoEntity.findAll(attributes, { where: payload });
}
}
module.exports = new PhotoDao();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment