i am developing a nestjs application where i am using the package migrate-mongo, i have init the migrate-mongo command with
npx migrate-mongo -m esm init
then i had to add "type" : "module" in my package.json, also this is my migrate-mongo-config.js file
const config = {
mongodb: {
url: 'mongodb://localhost:27017/persomic',
options: {
useNewUrlParser: true, // removes a deprecation warning when connecting
useUnifiedTopology: true, // removes a deprecating warning when connecting
},
},
migrationsDir: 'migrations',
changelogCollectionName: 'changelog',
migrationFileExtension: '.js',
useFileHash: true,
moduleSystem: 'esm',
};
export default config;
As far as i know migrate-mongo supports ts files from version 10.0.0, but when i add migrationFileExtension: '.ts', i get the error
Unexpected token export
in one of my migration file which is the following
export const up = async (db, client) => { };
export const down = async (db, client) => { };
but when i change the config to .js it works fine. Works fine creating migration files, but doesnt work when used up command
the problems i am facing right now:
- cannot work with ts files
- have to add type: module to src package.json which can give rise to additional problems( is there any workaround?)
- Also no migrations collection is being created in my mongodb, but changelog(default collection name) is being created.