|
@@ -38,7 +38,7 @@ async function updateUserData(host, database, cename, data, res) {
|
|
|
console.log(`更新用户数据:${username}`);
|
|
|
// 使用 upsert 更新或插入文档
|
|
|
await collection.updateOne(
|
|
|
- { [dateKey]: { $exists: true }, [`${dateKey}.${username}`]: { $exists: true } }, // 查询条件
|
|
|
+ { [dateKey]: { $exists: true } }, // 查询条件, [`${dateKey}.${username}`]: { $exists: true }
|
|
|
{
|
|
|
$push: { [`${dateKey}.${username}`]: data[dateKey][username] }, // 将用户数据推入数组
|
|
|
},
|
|
@@ -52,10 +52,10 @@ async function updateUserData(host, database, cename, data, res) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
+/*
|
|
|
// 示例调用
|
|
|
updateUserData("mongodb://root:usestudio-1@123.58.32.151:11641?authSource=admin", "cocolog", "applog", {
|
|
|
- "2025-03-24": {
|
|
|
+ "2025-04-01": {
|
|
|
"username":
|
|
|
{
|
|
|
userid: "",
|