/** @module _modules/_baseRecord */ /** @module _modules/allModules */ /** * --- BASERECORD --- * Data common to every single data TYPE * Universal fields required for storing anything */ class _baseRecord { /** * Standard record to extend with more detail */ constructor() { this.createdAt = new Date().toJSON() this._id = Date.now().toString() this.lastUpdatedAt = null /** Set in subtype (ticket, user, etc) */ this.type = null this._update() } /** Internally record update time */ _update() { this.lastUpdatedAt = new Date().toJSON() } } /** * --- MODULES --- * Reusable bits to add to data TYPES * Make these as generic and reusable as possible! * * TODO: Destructure all these arguements */ const allModules = { /** * Use parent() for anything that has a parent */ parent: ({ id = '' }) => { const module = { parentId: id, } return module }, /** * Use hourly() for anything that needs to track money * time */ hourly: ({ hours, rate }) => { let module = { hours: hours, rate: rate, total: hours * rate, } return module }, /** * Use id() for anything that needs to store contact information * (People, companies, etc) */ contact: ({ name, email }) => { const module = { name: name, email: email, } // This is used for checking, maybe validation in the future(?) if (name) { module.name = name } if (email) { module.email = email } return module }, /** * Use transaction() for anything that needs to track money * (Donations, fees, etc) */ transaction: ({ amount, date }) => { let module = { amount: amount, date: date, } return module }, /** * Use subjNote() for anything that needs just a title and short note * (Blog post, Quick notes, etc) */ subjNote: ({ subject, note, status }) => { let module = { subject: subject, note: note, status: status, } if (!status) { module.status = 'draft' } else { module.status = status } return module }, /** * Use location() for anything that needs to store location information * (People, companies, etc) */ location: ({ street = '', apt = '', city = '', state = '', zip = 11111, }) => { const module = { address: street, apt: apt, city: city, state: state, zip: zip, } return module }, } export { _baseRecord, allModules }