UNPKG

2.58 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16exports.SnakeNamingStrategy = void 0;
17var typeorm_1 = require("typeorm");
18var StringUtils_1 = require("typeorm/util/StringUtils");
19var SnakeNamingStrategy = /** @class */ (function (_super) {
20 __extends(SnakeNamingStrategy, _super);
21 function SnakeNamingStrategy() {
22 return _super.call(this) || this;
23 }
24 SnakeNamingStrategy.prototype.tableName = function (className, customName) {
25 return customName ? customName : StringUtils_1.snakeCase(className) + "s";
26 };
27 SnakeNamingStrategy.prototype.columnName = function (propertyName, customName, embeddedPrefixes) {
28 if (embeddedPrefixes === void 0) { embeddedPrefixes = []; }
29 return (StringUtils_1.snakeCase(embeddedPrefixes.join('_')) + (customName ? customName : StringUtils_1.snakeCase(propertyName)));
30 };
31 SnakeNamingStrategy.prototype.relationName = function (propertyName) {
32 return StringUtils_1.snakeCase(propertyName);
33 };
34 SnakeNamingStrategy.prototype.joinColumnName = function (relationName, referencedColumnName) {
35 return StringUtils_1.snakeCase(relationName + "_" + referencedColumnName);
36 };
37 SnakeNamingStrategy.prototype.joinTableName = function (firstTableName, secondTableName) {
38 return StringUtils_1.snakeCase(firstTableName + "_" + secondTableName);
39 };
40 SnakeNamingStrategy.prototype.joinTableColumnName = function (tableName, propertyName, columnName) {
41 return StringUtils_1.snakeCase(tableName + "_" + (columnName ? columnName : propertyName));
42 };
43 SnakeNamingStrategy.prototype.classTableInheritanceParentColumnName = function (parentTableName, parentTableIdPropertyName) {
44 return StringUtils_1.snakeCase(parentTableName + "_" + parentTableIdPropertyName);
45 };
46 return SnakeNamingStrategy;
47}(typeorm_1.DefaultNamingStrategy));
48exports.SnakeNamingStrategy = SnakeNamingStrategy;
49//# sourceMappingURL=SnakeNamingStrategy.js.map
\No newline at end of file