const MongoClient = require('mongodb').MongoClient;
const fs = require('fs');
const dbName = 'test';
const collectionName = 'Artwork'
const MONGO_HOST = '138.68.129.143';
const MONGO_PORT = '56728';
const newMongo = 'mongodb+srv://waqarmoralis:[email protected]/?retryWrites=true&w=majority';
const client = new MongoClient(`mongodb://${MONGO_HOST}:${MONGO_PORT}`, { useUnifiedTopology:true });
const newClient = new MongoClient(newMongo, { useUnifiedTopology:true });
client.connect(function(err) {
console.log('Connected successfully to server');
const db = client.db(dbName);
getDocuments(db, function(docs) {
console.log('Closing connection.');
client.close();
// Write to file
try {
fs.writeFileSync('out_file.json', JSON.stringify(docs));
console.log('Done writing to file.');
}
catch(err) {
console.log('Error writing to file', err)
}
});
})
No error show migrate succefully but afte
r migrate get the data which is provide by moralis
how to export my own data
Did you whitelist your ip as show in this docs.
getting the bulkoperation issue while migrating the data
you can connect directly to mongo db and make a dump for the entire database
after that you can save that dump and load it in a new database
how can you explain the process
you can search on google how to use mongo dump or any other tool that you have to connect directly to mongo db database
you can read here about mongodump
how to export all the data from you old server i know how to import to mongo db but there is no option in you old server how to export
I donβt understand what you mean, first part says that you know how to do it and second part says that there is no option?
mean i need to migrate all the data from your old serve so I donot know how to export from there
you can use mongodump to dump the entire database instead of that migration code
after that you have a backup to the database locally that you can use it anytime, you can load it in another database
you could try something like (this is not the complete command, you will also have to specify the connection string for your server that will have the server IP for your database and you will have to add to whitelisting your public IP in order to be able to access it)
mongodump -d parse --archive --gzip > database_backup.gz