Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static get relationMappings()
{
// to avoid require loop:
const Rooms = require('./model');
return {
parent_room: {
relation: Model.BelongsToOneRelation,
modelClass: Rooms,
join: {
from: 'rooms_change_points.room_id',
to: 'rooms.id'
}
},
next_room: {
relation: Model.HasOneRelation,
modelClass: Rooms,
join: {
from: 'rooms_change_points.next_room_id',
to: 'rooms.id'
}
}
}
}
}
// Return the object if it is already fetched
if (self[relationName] !== undefined) {
return handleResult(self[relationName], options);
}
// Only pass single column relations through data loader
if (relatedCols.length !== 1 || ownerCols.length !== 1) {
await self.$loadRelated(relationName, undefined, options.knex);
return handleResult(self[relationName], options);
}
if (
relation instanceof Model.BelongsToOneRelation ||
relation instanceof Model.HasOneRelation
) {
self[relationName] = await relation.relatedModelClass
.loadByColumn(relatedCols[0], self[ownerCols[0]], options);
return handleResult(self[relationName], options);
}
if (relation instanceof Model.HasManyRelation) {
const modify = relation.modify;
if (String(modify).indexOf('noop') !== -1) {
self[relationName] = await relation.relatedModelClass
.loadManyByColumn(relatedCols[0], self[ownerCols[0]], options);
return handleResult(self[relationName], options);
}
self[relationName] = await relation.relatedModelClass
static get relationMappings () {
return {
owner: {
relation: Model.HasOneRelation,
modelClass: User,
join: {
from: 'redirection_host.owner_user_id',
to: 'user.id'
},
modify: function (qb) {
qb.where('user.is_deleted', 0);
qb.omit(['id', 'created_on', 'modified_on', 'is_deleted', 'email', 'roles']);
}
},
certificate: {
relation: Model.HasOneRelation,
modelClass: Certificate,
join: {
from: 'redirection_host.certificate_id',
to: 'certificate.id'
},
modify: function (qb) {
qb.where('certificate.is_deleted', 0);
qb.omit(['id', 'created_on', 'modified_on', 'is_deleted']);
}
}
};
}
}
static get relationMappings () {
return {
owner: {
relation: Model.HasOneRelation,
modelClass: User,
join: {
from: 'redirection_host.owner_user_id',
to: 'user.id'
},
modify: function (qb) {
qb.where('user.is_deleted', 0);
qb.omit(['id', 'created_on', 'modified_on', 'is_deleted', 'email', 'roles']);
}
},
certificate: {
relation: Model.HasOneRelation,
modelClass: Certificate,
join: {
from: 'redirection_host.certificate_id',
to: 'certificate.id'
static get relationMappings() {
const IdAttributeType = require('./id-attribute-type').default;
const Repository = require('./repository').default;
return {
idAttributeType: {
relation: Model.HasOneRelation,
modelClass: IdAttributeType,
join: {
from: `${this.tableName}.attributeTypeId`,
to: `${IdAttributeType.tableName}.id`
}
},
defaultRepository: {
relation: Model.HasOneRelation,
modelClass: Repository,
join: {
from: `${this.tableName}.defaultRepositoryId`,
to: `${Repository.tableName}.id`
}
}
};
}
modelClass: Attachment,
join: {
from: 'user.id',
to: 'attachment.user_id',
},
},
verificationToken: {
relation: Model.HasOneRelation,
modelClass: VerificationToken,
join: {
from: 'user.id',
to: 'verification_token.user_id',
},
},
resetToken: {
relation: Model.HasOneRelation,
modelClass: ResetToken,
join: {
from: 'user.id',
to: 'reset_token.user_id',
},
},
comments: {
relation: Model.HasManyRelation,
modelClass: Comment,
join: {
from: 'user.id',
to: 'comment.comment_author_id',
},
},
};
}
public name?: string
public static tableName = 'roles'
public static relationMappings = {
user: {
join: {
from: 'roles.id',
through: {
from: 'roles_roleable.role_id',
to: 'roles_roleable.user_id',
},
to: 'users.id',
},
modelClass: __dirname + '/user',
relation: Model.HasOneRelation,
},
}
}
* @prop {number} damage - the dX to roll
* @prop {number} number_of_hits - how many times to roll that dice
* @prop {string} crit_range - range for critical hit
* @prop {number} crit_multiplier - multiplication of critical damage
* @prop {string} type - weapon's type (short sword, bow, boomerang, etc.)
* @prop {string} modifier - the modifier to use with the weapon (Strength, Dexterity, Wisdom)
* @prop {number} range - how far a ranged weapon can fire
* @prop {number} ammo - how much ammo a ranged weapon has
* @prop {string} last_modified_by - the id of the last user to modify the weapon
*/
export class Weapon extends Model {
static tableName = 'weapon';
static relationMappings: RelationMappings = {
element: {
relation: Model.HasOneRelation,
modelClass: Element,
join: {
from: `${Weapon.tableName}.id`,
to: `${Element.tableName}.weapon_id`
}
}
};
id: string;
last_modified: string;
name: string;
character_id: string;
damage: number;
number_of_hits: number;
crit_range: string;
crit_multiplier: number;
static get relationMappings() {
const IdAttributeType = require('./id-attribute-type').default;
const Repository = require('./repository').default;
return {
idAttributeType: {
relation: Model.HasOneRelation,
modelClass: IdAttributeType,
join: {
from: `${this.tableName}.attributeTypeId`,
to: `${IdAttributeType.tableName}.id`
}
},
defaultRepository: {
relation: Model.HasOneRelation,
modelClass: Repository,
join: {
from: `${this.tableName}.defaultRepositoryId`,
to: `${Repository.tableName}.id`
}
}
};
}
modelClass: Users,
join: {
from: 'players.user_id',
to: 'users.id'
}
},
stats: {
relation: Model.HasOneRelation,
modelClass: PlayersStats,
join: {
from: 'players.id',
to: 'players_stats.player_id'
}
},
state: {
relation: Model.HasOneRelation,
modelClass: PlayersState,
join: {
from: 'players.id',
to: 'players_state.player_id'
}
}
}
}