|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
import { Injectable, Logger } from '@nestjs/common'; |
|
|
|
|
import { isSystemColumn } from 'nocodb-sdk'; |
|
|
|
|
import { isLinksOrLTAR, isSystemColumn } from 'nocodb-sdk'; |
|
|
|
|
import * as XLSX from 'xlsx'; |
|
|
|
|
import papaparse from 'papaparse'; |
|
|
|
|
import { nocoExecute } from '~/utils'; |
|
|
|
|
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; |
|
|
|
|
import type { PathParams } from '~/helpers/dataHelpers'; |
|
|
|
|
import type { NcContext } from '~/interface/config'; |
|
|
|
|
import type { Filter } from '~/models'; |
|
|
|
|
import type LinkToAnotherRecordColumn from '../models/LinkToAnotherRecordColumn'; |
|
|
|
|
import { nocoExecute } from '~/utils'; |
|
|
|
|
import { getDbRows, getViewAndModelByAliasOrId } from '~/helpers/dataHelpers'; |
|
|
|
|
import { Base, Column, Model, Source, View } from '~/models'; |
|
|
|
|
import { NcBaseError, NcError } from '~/helpers/catchError'; |
|
|
|
@ -41,6 +42,27 @@ export class DatasService {
|
|
|
|
|
view = modelAndView.view; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// check for linkColumnId query param and handle it
|
|
|
|
|
if (param.query.linkColumnId) { |
|
|
|
|
const linkColumn = await Column.get<LinkToAnotherRecordColumn>(context, { |
|
|
|
|
colId: param.query.linkColumnId, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
!linkColumn || |
|
|
|
|
!isLinksOrLTAR(linkColumn) || |
|
|
|
|
linkColumn.colOptions.fk_related_model_id !== model.id |
|
|
|
|
) { |
|
|
|
|
NcError.fieldNotFound(param.query?.linkColumnId, { |
|
|
|
|
customMessage: `Link column with id ${param.query.linkColumnId} not found`, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (linkColumn.colOptions.fk_target_view_id) { |
|
|
|
|
view = await View.get(context, linkColumn.colOptions.fk_target_view_id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return await this.getDataList(context, { |
|
|
|
|
model, |
|
|
|
|
view, |
|
|
|
|