Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// json key for embedded json
if (!relation.jsonKey) {
relation.jsonKey = underscore(relation.propertyName);
}
// key in top level json
if (!relation.topLevelJsonKey) {
relation.topLevelJsonKey = tableize(relation.propertyName);
}
// foreign key with ids of relations
if (!relation.foreignKey) {
if (relation.isHasMany) {
relation.foreignKey = foreign_key(singularize(relation.propertyName)) + 's';
} else if (relation.isHasOne) {
relation.foreignKey = foreign_key(relation.propertyName);
}
}
let name = upperCaseFirstLetter(relation.propertyName);
if (relation.isHasMany) name = singularize(name);
// method name to add single relation, will be used as alias
if (!relation.setMethodName) {
relation.setMethodName = `set${name}`;
}
// method name to remove single relation, will be used as alias
if (!relation.removeMethodName) {
relation.removeMethodName = `remove${name}`;
// json key for embedded json
if (!relation.jsonKey) {
relation.jsonKey = underscore(relation.propertyName);
}
// key in top level json
if (!relation.topLevelJsonKey) {
relation.topLevelJsonKey = tableize(relation.propertyName);
}
// foreign key with ids of relations
if (!relation.foreignKey) {
if (relation.isHasMany) {
relation.foreignKey = foreign_key(singularize(relation.propertyName)) + 's';
} else if (relation.isHasOne) {
relation.foreignKey = foreign_key(relation.propertyName);
}
}
let name = upperCaseFirstLetter(relation.propertyName);
if (relation.isHasMany) name = singularize(name);
// method name to add single relation, will be used as alias
if (!relation.setMethodName) {
relation.setMethodName = `set${name}`;
}
// method name to remove single relation, will be used as alias
if (!relation.removeMethodName) {
relation.removeMethodName = `remove${name}`;
}