MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / reorderDatasetRow

Function reorderDatasetRow

packages/server/src/services/dataset/index.ts:93–116  ·  view source on GitHub ↗
(datasetId: string, rows: any[], workspaceId: string)

Source from the content-addressed store, hash-verified

91}
92
93const reorderDatasetRow = async (datasetId: string, rows: any[], workspaceId: string) => {
94 try {
95 const appServer = getRunningExpressApp()
96 await appServer.AppDataSource.transaction(async (entityManager) => {
97 // rows are an array of { id: string, sequenceNo: number }
98 // update the sequence numbers in the DB
99 for (const row of rows) {
100 const item = await entityManager.getRepository(DatasetRow).findOneBy({
101 id: row.id
102 })
103 if (!item) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Dataset Row ${row.id} not found`)
104 item.sequenceNo = row.sequenceNo
105 await entityManager.getRepository(DatasetRow).save(item)
106 }
107 await changeUpdateOnDataset(datasetId, workspaceId, entityManager)
108 })
109 return { message: 'Dataset row reordered successfully' }
110 } catch (error) {
111 throw new InternalFlowiseError(
112 StatusCodes.INTERNAL_SERVER_ERROR,
113 `Error: datasetService.reorderDatasetRow - ${getErrorMessage(error)}`
114 )
115 }
116}
117
118const _readCSV = async (stream: Readable, results: any[]) => {
119 return new Promise((resolve, reject) => {

Callers

nothing calls this directly

Calls 3

getRunningExpressAppFunction · 0.90
getErrorMessageFunction · 0.90
changeUpdateOnDatasetFunction · 0.85

Tested by

no test coverage detected