Skip to content

Commit

Permalink
feat: fetch index information for models
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
  • Loading branch information
aaqilniz committed Oct 13, 2024
1 parent b604aa0 commit 04d2356
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ DataSource.prototype.discoverSchemas = function(tableName, options, cb) {

columns.forEach(function(item) {
const propName = nameMapper('column', item.columnName);
schema.properties[propName] = {
const propertyDetails = {
type: item.type,
required: !item.generated && (item.nullable === 'N' || item.nullable === 'NO' ||
item.nullable === 0 || item.nullable === false),
Expand All @@ -1726,7 +1726,16 @@ DataSource.prototype.discoverSchemas = function(tableName, options, cb) {
precision: item.dataPrecision,
scale: item.dataScale,
generated: item.generated || false,
};
}

Check failure on line 1729 in lib/datasource.js

View workflow job for this annotation

GitHub Actions / Code Lint

Missing semicolon
if (
item.indexType === 'BTREE' &&
item.indexName !== 'PRIMARY' &&

Check failure on line 1732 in lib/datasource.js

View workflow job for this annotation

GitHub Actions / Code Lint

Multiple spaces found before '&&'
!item.isForeignKey
) {
propertyDetails.index = {unique: true}

Check failure on line 1735 in lib/datasource.js

View workflow job for this annotation

GitHub Actions / Code Lint

Missing semicolon
}
schema.properties[propName] = propertyDetails;

if (pks[item.columnName]) {
schema.properties[propName].id = pks[item.columnName];
}
Expand Down

0 comments on commit 04d2356

Please sign in to comment.