From 8b09a51608decddf39caaf99eb8b5f1bd10a22a9 Mon Sep 17 00:00:00 2001 From: Krzysztof Orkisz Date: Tue, 21 May 2024 13:03:46 +0200 Subject: [PATCH 1/2] add type annotations in sample migrations --- samples/commonjs/migration.js | 10 ++++++++++ samples/esm/migration.js | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/samples/commonjs/migration.js b/samples/commonjs/migration.js index f893136..247b7d3 100644 --- a/samples/commonjs/migration.js +++ b/samples/commonjs/migration.js @@ -1,4 +1,9 @@ module.exports = { + /** + * @param db {import('mongodb').Db} + * @param client {import('mongodb').MongoClient} + * @returns {Promise} + */ async up(db, client) { // TODO write your migration here. // See https://github.com/seppevs/migrate-mongo/#creating-a-new-migration-script @@ -6,6 +11,11 @@ module.exports = { // await db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: true}}); }, + /** + * @param db {import('mongodb').Db} + * @param client {import('mongodb').MongoClient} + * @returns {Promise} + */ async down(db, client) { // TODO write the statements to rollback your migration (if possible) // Example: diff --git a/samples/esm/migration.js b/samples/esm/migration.js index d1c4d22..2d20aef 100644 --- a/samples/esm/migration.js +++ b/samples/esm/migration.js @@ -1,3 +1,8 @@ +/** + * @param db {import('mongodb').Db} + * @param client {import('mongodb').MongoClient} + * @returns {Promise} + */ export const up = async (db, client) => { // TODO write your migration here. // See https://github.com/seppevs/migrate-mongo/#creating-a-new-migration-script @@ -5,6 +10,11 @@ export const up = async (db, client) => { // await db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: true}}); }; +/** + * @param db {import('mongodb').Db} + * @param client {import('mongodb').MongoClient} + * @returns {Promise} + */ export const down = async (db, client) => { // TODO write the statements to rollback your migration (if possible) // Example: From a868af9495be1546716648963ebdd01e141b8cbf Mon Sep 17 00:00:00 2001 From: Krzysztof Orkisz Date: Tue, 21 May 2024 13:05:52 +0200 Subject: [PATCH 2/2] update readme --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 746e198..f5a6367 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,11 @@ Created: migrations/20160608155948-blacklist_the_beatles.js A new migration file is created in the 'migrations' directory: ````javascript module.exports = { + /** + * @param db {import('mongodb').Db} + * @param client {import('mongodb').MongoClient} + * @returns {Promise} + */ up(db, client) { // TODO write your migration here. Return a Promise (and/or use async & await). // See https://github.com/seppevs/migrate-mongo/#creating-a-new-migration-script @@ -112,6 +117,11 @@ module.exports = { // return db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: true}}); }, + /** + * @param db {import('mongodb').Db} + * @param client {import('mongodb').MongoClient} + * @returns {Promise} + */ down(db, client) { // TODO write the statements to rollback your migration (if possible) // Example: