Editing mongoDB via external script

Hey guys,

Context:
I have encountered an issue while attempting to edit my MongoDB database through an external script, which connects to the same database utilized by my Parse server.

The script relies on the mongodb package as its sole dependency. Its purpose is to write data to random classes and occasionally add new classes or columns to existing ones.

Problem:
However, after running the script, I noticed that the Parse dashboard does not reflect any of the newly created classes or columns. And if I check the database, the _id’s created aren’t in the same format as the Parse created ones.

Is there any other solution besides running a parse-server instance in the script just to edit my mongoDB database?

Edit: It looks like _SCHEMA table is the one I need to update

Doesn’t compatible with parse-server objectId and mongoDb auto-created id, parse-server objectId calculated in cryptoUtils.js. If you want to do consistent work, you can use this class.
ex:

// script.js
const { newObjectId } = require('parse-server/lib/cryptoUtils');
//...
{
    _id: newObjectId(),
    name: 'admin'
}

If you created a new class or columns, you should update schemas according to your changes.

1 Like