Skip to content

Commit

Permalink
extended ConstraintBuilder and ColumnBuilder api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaroslav Bobrowski committed Aug 13, 2024
1 parent 896ffe5 commit a06f33e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## 1.9.8

* added method `.archiveCascade` to `ConstraintBuilder`
* added method `.finalCascade` to `ConstraintBuilder`
* added method `.decimalDigits` to `ColumnBuilder`
* added method `.showMemberColumns` to `ColumnBuilder`

## 1.9.7

* added `AsyncApi` to implement the async version of the `.doCall` method
Expand Down
56 changes: 56 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,25 @@ function grudStructorizer(baseUrl, options) {
return this;
}

/**
*
* @param decimalDigits {number}
* @returns {ColumnBuilder}
*/
decimalDigits(decimalDigits) {
if (this.column.kind !== "numeric") {
throw new Error("column " + this.column.name + " should be of type numeric to set 'decimalDigits(...)'");
}

if (!_.isInteger(decimalDigits) || decimalDigits < 0) {
throw new Error("parameter 'decimalDigits' should be a positive integer number");
}

this.column.decimalDigits = decimalDigits;

return this;
}

/**
*
* @param toTable {Table|number}
Expand Down Expand Up @@ -791,6 +810,19 @@ function grudStructorizer(baseUrl, options) {
return this;
}

/**
*
* @param showMemberColumns {boolean}
* @returns {ColumnBuilder}
*/
showMemberColumns(showMemberColumns) {
if (this.column.kind !== "group") {
throw new Error("column " + this.column.name + " should be of type 'group' to set 'showMemberColumns(...)'");
}

this.column.showMemberColumns = _.isBoolean(showMemberColumns) ? showMemberColumns : true;
}

/**
*
* @param formatPattern {string}
Expand Down Expand Up @@ -911,6 +943,8 @@ function grudStructorizer(baseUrl, options) {

/**
* @typedef {{deleteCascade: boolean}} ConstraintDeleteCascade
* @typedef {{archiveCascade: boolean}} ConstraintArchiveCascade
* @typedef {{finalCascade: boolean}} ConstraintFinalCascade
*/

/**
Expand Down Expand Up @@ -966,6 +1000,28 @@ function grudStructorizer(baseUrl, options) {
deleteCascade: _.isBoolean(deleteCascade) ? deleteCascade : true
};
}

/**
*
* @param archiveCascade {boolean}
* @returns {ConstraintArchiveCascade}
*/
static archiveCascade(archiveCascade) {
return {
archiveCascade: _.isBoolean(archiveCascade) ? archiveCascade : true
};
}

/**
*
* @param finalCascade {boolean}
* @returns {ConstraintFinalCascade}
*/
static finalCascade(finalCascade) {
return {
finalCascade: _.isBoolean(finalCascade) ? finalCascade : true
};
}
}

return {
Expand Down

0 comments on commit a06f33e

Please sign in to comment.