1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import db from '../db'
- import { DataTypes } from 'sequelize'
- const Account = db.define('account', {
- key: {
- type: DataTypes.STRING,
- primaryKey: true,
- },
- format: DataTypes.STRING,
- about: DataTypes.TEXT,
- })
- Account.findAllWithIncludes = function () {
- return this.findAll({
- include: [
- { association: 'validated', attributes: ['id', 'timestamp'] },
- { model: db.models.member, attributes: ['handle'] },
- ],
- })
- }
- Account.findByIdWithIncludes = function (id: number) {
- return this.findByPk(id, {
- include: [
- { association: 'validated', attributes: ['id', 'timestamp'] },
- { model: db.models.member, attributes: ['handle'] },
- ],
- })
- }
- Account.findWithIncludes = function (args: { where: any }) {
- return this.findAll({
- ...args,
- include: [
- { association: 'validated', attributes: ['id', 'timestamp'] },
- { model: db.models.member, attributes: ['handle'] },
- ],
- })
- }
- export default Account
|