I would need help and explanation, I created a given migration script in local version but it works once on two wells with a concern that prevents the set from time to time.
const { MongoClient } = require("mongodb");
const url = "mongodb://127.0.0.1:27017";
const dbName = "";
const collectionName = "";
const client = new MongoClient(url);
async function main() {
await client.connect();
console.log("Connected successfully to server");
const db = client.db(dbName);
const collection = db.collection(collectionName);
const result = await collection.find().toArray();
result.map(async (d) => {
await collection.updateOne(
{ _id: d._id },
{
$set: {
ownerName: d.owners.primary,
coowners: d.owners.additional,
ownerID: "",
discrim: "",
status: "",
serverCount: 0,
shardCount: 0,
analytics_visitors: 0,
analytics_invites: 0,
country: {},
rates: {},
dcwebhook: "",
token: "",
},
$unset: {
note: "",
invite: "",
state: "",
donation: "",
servers: "",
auth: "",
ratelimit: "",
botLibrary: "",
inRecomendationQueue: "",
},
$rename: {
botid: "botID",
avatar: "logo",
description: "longDesc",
long: "shortDesc",
banner: "backURL",
addedAt: "Date",
certify: "certificate",
likes: "votes",
},
}
);
});
return "Action terminer";
}
main()
.then(console.log)
.catch(console.error)
.finally(() => client.close());