-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#449-1 채팅 검증 개선 및 오류 수정
- Loading branch information
Showing
9 changed files
with
88 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Issue #449-1을 해결하기 위한 DB 마이그레이션 스크립트입니다. | ||
// chat type 중 settlement와 payment를 서로 교체합니다. | ||
// https://github.com/sparcs-kaist/taxi-back/issues/449 | ||
|
||
const { MongoClient } = require("mongodb"); | ||
const { mongo: mongoUrl } = require("../loadenv"); | ||
|
||
const client = new MongoClient(mongoUrl); | ||
const db = client.db("taxi"); | ||
const chats = db.collection("chats"); | ||
|
||
async function run() { | ||
try { | ||
for await (const doc of chats.find()) { | ||
if (doc.type === "settlement" || doc.type === "payment") { | ||
await chats.findOneAndUpdate( | ||
{ _id: doc._id }, | ||
{ | ||
$set: { | ||
type: doc.type === "settlement" ? "payment" : "settlement", | ||
}, | ||
} | ||
); | ||
} | ||
} | ||
} catch (err) { | ||
console.log(err); | ||
} finally { | ||
await client.close(); | ||
} | ||
} | ||
run().then(() => { | ||
console.log("Done!"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters