Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i export schema mongodb without value?

I want to export a mongodb collection without a value, I've tried using the mongodb compass but it's not quite what I want

like image 309
DZS Avatar asked Dec 20 '25 22:12

DZS


1 Answers

Unfortunately, that's not implemented in mongodump.

You'd have to make a full database dump, and trim afterwards so you're only left with *.metadata.json.

On the Linux / Mac / *nix command line, you can do:

mongodump --out=mydumpdir
rm mydumpdir/*/*.bson

You can then import it elsewhere using mongorestore mydumpdir.

like image 156
rkok Avatar answered Dec 24 '25 01:12

rkok



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!