seppevs / migrate-mongo

A database migration tool for MongoDB in Node
MIT License
926 stars 163 forks source link

TypeError: db.runCommand is not a function #429

Closed vytautas-pranskunas- closed 1 year ago

vytautas-pranskunas- commented 1 year ago

I get this error when trying to run this script:

await db.runCommand({
                    collMod: 'users',
                    validator: {
                        $jsonSchema: {
                            bsonType: 'object',
                            properties: {
                                details: {
                                    bsonType: 'object',
                                    properties: {
                                        type: {
                                            enum: ['valueOne', 'valueTwo'],
                                            description: 'Can only be one of the enum values',
                                        },
                                    },
                                },
                            },
                        },
                    },
                });
vytautas-pranskunas- commented 1 year ago

is this project still supporte? because no response for 3 weeks...

seppevs commented 1 year ago

Try to install the latest mongodb version in your project. The issue is not caused by migrate-mongo, so I'm closing this.

vytautas-pranskunas- commented 1 year ago

If i am running this command via mongodb shell all works good. It is failing only once run via migrate mongo.

seppevs commented 1 year ago

migrate-mongo is just a wrapper project around the mongodb node.js dependency. I suggest to see which version of mongodb is installed in your migration project.

marxxxx commented 5 months ago

@vytautas-pranskunas- In case this is still relevant. I was receiving the same error but was able to solve it by calling db.command()instead of db.runCommand(). The parameters are the same.

This SO-Thread was pointing me in the right direction: https://stackoverflow.com/questions/49765120/node-mongo-db-runcommand-is-not-a-function