|
|
@ -1397,56 +1397,57 @@ export default async ( |
|
|
|
return rec; |
|
|
|
return rec; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function nocoReadData(sDB, table, aTbl) { |
|
|
|
async function processRecords(records, sDB, table, insertJobs) { |
|
|
|
ncLinkDataStore[table.title] = {}; |
|
|
|
// This function (`page`) will get called for each page of records.
|
|
|
|
const insertJobs: Promise<any>[] = []; |
|
|
|
logBasic( |
|
|
|
|
|
|
|
`:: ${table.title} : ${recordCnt + 1} ~ ${(recordCnt += pageSize)}` |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
async function processRecords(records) { |
|
|
|
// await Promise.all(
|
|
|
|
// This function (`page`) will get called for each page of records.
|
|
|
|
// records.map(record => _callback(sDB, table, record))
|
|
|
|
logBasic( |
|
|
|
// );
|
|
|
|
`:: ${table.title} : ${recordCnt + 1} ~ ${(recordCnt += pageSize)}` |
|
|
|
const ncRecords = []; |
|
|
|
); |
|
|
|
for (let i = 0; i < records.length; i++) { |
|
|
|
|
|
|
|
const r = await nocoBaseDataProcessing_v2(sDB, table, records[i]); |
|
|
|
|
|
|
|
ncRecords.push(r); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// await Promise.all(
|
|
|
|
// wait for previous job's to finish
|
|
|
|
// records.map(record => _callback(sDB, table, record))
|
|
|
|
await Promise.all(insertJobs); |
|
|
|
// );
|
|
|
|
|
|
|
|
const ncRecords = []; |
|
|
|
|
|
|
|
for (let i = 0; i < records.length; i++) { |
|
|
|
|
|
|
|
const r = await nocoBaseDataProcessing_v2(sDB, table, records[i]); |
|
|
|
|
|
|
|
ncRecords.push(r); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wait for previous job's to finish
|
|
|
|
const _perfStart = recordPerfStart(); |
|
|
|
await Promise.all(insertJobs); |
|
|
|
insertJobs.push( |
|
|
|
|
|
|
|
api.dbTableRow.bulkCreate( |
|
|
|
|
|
|
|
'nc', |
|
|
|
|
|
|
|
sDB.projectName, |
|
|
|
|
|
|
|
table.id, // encodeURIComponent(table.title),
|
|
|
|
|
|
|
|
ncRecords |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
recordPerfStats(_perfStart, 'dbTableRow.bulkCreate'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const _perfStart = recordPerfStart(); |
|
|
|
async function nocoReadData(sDB, table, aTbl) { |
|
|
|
insertJobs.push( |
|
|
|
ncLinkDataStore[table.title] = {}; |
|
|
|
api.dbTableRow.bulkCreate( |
|
|
|
const insertJobs: Promise<any>[] = []; |
|
|
|
'nc', |
|
|
|
|
|
|
|
sDB.projectName, |
|
|
|
|
|
|
|
table.id, // encodeURIComponent(table.title),
|
|
|
|
|
|
|
|
ncRecords |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
recordPerfStats(_perfStart, 'dbTableRow.bulkCreate'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// skip virtual columns
|
|
|
|
// skip virtual columns
|
|
|
|
const fieldsArray = aTbl.columns |
|
|
|
const fieldsArray = aTbl.columns |
|
|
|
.filter(a => !['formula', 'lookup', 'rollup'].includes(a.type)) |
|
|
|
.filter(a => !['formula', 'lookup', 'rollup'].includes(a.type)) |
|
|
|
.map(a => a.name); |
|
|
|
.map(a => a.name); |
|
|
|
|
|
|
|
|
|
|
|
if (enableLocalCache) { |
|
|
|
if ( |
|
|
|
|
|
|
|
enableLocalCache && |
|
|
|
|
|
|
|
fs2.existsSync(`./migrationCache/data/${table.title}_0.json`) |
|
|
|
|
|
|
|
) { |
|
|
|
// check if cached file exists for this table
|
|
|
|
// check if cached file exists for this table
|
|
|
|
const f = `./migrationCache/data/${table.title}_${recordCnt / |
|
|
|
let f = `./migrationCache/data/${table.title}_${recordCnt / |
|
|
|
pageSize}.json`;
|
|
|
|
pageSize}.json`;
|
|
|
|
|
|
|
|
|
|
|
|
while (fs2.existsSync(f)) { |
|
|
|
while (fs2.existsSync(f)) { |
|
|
|
const records = jsonfile.readFileSync(f); |
|
|
|
const records = jsonfile.readFileSync(f); |
|
|
|
logBasic( |
|
|
|
await processRecords(records, sDB, table, insertJobs); |
|
|
|
`:: ${table.title} : ${recordCnt + 1} ~ ${(recordCnt += pageSize)}` |
|
|
|
f = `./migrationCache/data/${table.title}_${recordCnt / pageSize}.json`; |
|
|
|
); |
|
|
|
|
|
|
|
await processRecords(records); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// scenarios to handle
|
|
|
|
// scenarios to handle
|
|
|
@ -1476,7 +1477,7 @@ export default async ( |
|
|
|
); |
|
|
|
); |
|
|
|
// console.log(JSON.stringify(records, null, 2));
|
|
|
|
// console.log(JSON.stringify(records, null, 2));
|
|
|
|
|
|
|
|
|
|
|
|
await processRecords(records); |
|
|
|
await processRecords(records, sDB, table, insertJobs); |
|
|
|
|
|
|
|
|
|
|
|
// To fetch the next page of records, call `fetchNextPage`.
|
|
|
|
// To fetch the next page of records, call `fetchNextPage`.
|
|
|
|
// If there are more records, `page` will get called again.
|
|
|
|
// If there are more records, `page` will get called again.
|
|
|
|