mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 10:19:10 +00:00
v2: init -- UI is nuked from orbit, major app restructuring
This commit is contained in:
parent
c6f5b55c1c
commit
b8da886601
108 changed files with 6717 additions and 17430 deletions
14
models/Server.js
Normal file
14
models/Server.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
module.exports = (sql, DataTypes) => {
|
||||
return sql.define('server', {
|
||||
id: { // discord snowflake
|
||||
type: DataTypes.TEXT,
|
||||
primaryKey: true
|
||||
},
|
||||
categories: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
message: {
|
||||
type: DataTypes.TEXT
|
||||
}
|
||||
})
|
||||
}
|
7
models/Session.js
Normal file
7
models/Session.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = (sequelize, DataTypes) => {
|
||||
return sequelize.define('session', {
|
||||
id: { type: DataTypes.TEXT, primaryKey: true },
|
||||
maxAge: DataTypes.BIGINT,
|
||||
data: DataTypes.JSONB
|
||||
})
|
||||
}
|
37
models/index.js
Normal file
37
models/index.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const log = new (require('../logger'))('models/index')
|
||||
const glob = require('glob')
|
||||
const path = require('path')
|
||||
const util = require('../util/model-methods')
|
||||
|
||||
module.exports = (sql) => {
|
||||
const models = {}
|
||||
const modelFiles = glob.sync('./models/**/!(index).js')
|
||||
log.debug('found models', modelFiles)
|
||||
|
||||
modelFiles.forEach((v) => {
|
||||
let name = path.basename(v).replace('.js', '')
|
||||
if (v === './models/index.js') {
|
||||
log.debug('index.js hit, skipped')
|
||||
return
|
||||
}
|
||||
try {
|
||||
log.debug('importing..', v.replace('models/', ''))
|
||||
let model = sql.import(v.replace('models/', ''))
|
||||
models[name] = model
|
||||
} catch (err) {
|
||||
log.fatal('error importing model ' + v, err)
|
||||
process.exit(-1)
|
||||
}
|
||||
})
|
||||
|
||||
Object.keys(models).forEach((v) => {
|
||||
if (models[v].hasOwnProperty('__associations')) {
|
||||
models[v].__associations(models)
|
||||
}
|
||||
if (models[v].hasOwnProperty('__instanceMethods')) {
|
||||
models[v].__instanceMethods(models[v])
|
||||
}
|
||||
})
|
||||
|
||||
return models
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue