added additions_to_attachments fixment

This commit is contained in:
srgooglo 2022-10-13 21:55:24 +02:00
parent 615874d740
commit 3e84c4bea8

View File

@ -0,0 +1,26 @@
import { Post } from "../models"
import DBManager from "../classes/DbManager"
async function main() {
const dbManager = new DBManager()
await dbManager.connect()
const posts = await Post.find({}).catch(() => false)
for await (let post of posts) {
let postData = post.toObject()
if (postData["additions"]) {
// transform additions to attachments
postData["attachments"] = postData["additions"]
}
post.attachments = postData["attachments"]
await post.save()
}
console.log("Done!")
}
main()