You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
// 测试增量同步功能
|
|
const DatabaseService = require('./src/services/databaseService');
|
|
const config = require('./src/config/config');
|
|
|
|
async function testIncrementalSync() {
|
|
console.log('===== 测试增量同步功能 =====');
|
|
|
|
try {
|
|
// 连接数据库
|
|
await DatabaseService.connect();
|
|
|
|
// 检查配置
|
|
console.log('当前同步配置:', JSON.stringify(config.sync, null, 2));
|
|
|
|
// 查询需要同步的数据
|
|
console.log('查询需要同步的数据...');
|
|
const syncData = await DatabaseService.getAllSyncData();
|
|
|
|
console.log(`\n测试结果:`);
|
|
console.log(`增量同步模式: ${config.sync.incremental ? '开启' : '关闭'}`);
|
|
console.log(`查询到需要同步的数据条数: ${syncData.length}`);
|
|
|
|
if (syncData.length > 0) {
|
|
console.log('\n前3条数据示例:');
|
|
for (let i = 0; i < Math.min(3, syncData.length); i++) {
|
|
console.log(`\n用户ID: ${syncData[i].userId}`);
|
|
console.log(`公司: ${syncData[i].user.company}`);
|
|
console.log(`联系人: ${syncData[i].user.nickName}`);
|
|
console.log(`购买商品数量: ${syncData[i].cartItems.length}`);
|
|
console.log(`销售商品数量: ${syncData[i].products.length}`);
|
|
}
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('测试过程中发生错误:', error.message);
|
|
} finally {
|
|
// 断开数据库连接
|
|
await DatabaseService.disconnect();
|
|
}
|
|
}
|
|
|
|
// 执行测试
|
|
testIncrementalSync().catch(error => {
|
|
console.error('测试执行失败:', error.message);
|
|
process.exit(1);
|
|
});
|