148 lines
1.8 KiB
JavaScript
148 lines
1.8 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const ar_experiences = sequelize.define(
|
|
'ar_experiences',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
experience_name: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
platform: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"ios",
|
|
|
|
|
|
"android",
|
|
|
|
|
|
"web",
|
|
|
|
|
|
"zapbox"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"draft",
|
|
|
|
|
|
"published",
|
|
|
|
|
|
"archived"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
launch_instructions: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
ar_experiences.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.ar_experiences.belongsTo(db.characters, {
|
|
as: 'character',
|
|
foreignKey: {
|
|
name: 'characterId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
db.ar_experiences.hasMany(db.file, {
|
|
as: 'asset_bundle_files',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.ar_experiences.getTableName(),
|
|
belongsToColumn: 'asset_bundle_files',
|
|
},
|
|
});
|
|
|
|
|
|
db.ar_experiences.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.ar_experiences.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return ar_experiences;
|
|
};
|
|
|
|
|