db.createCollection( "contacts",{ validator: { $or:[{ phone: { $type: "string" } },{ email: { $regex: /@mongodb\.com$/ } },{ status: { $in: [ "Unknown", "Incomplete" ] } }]}} )
mongodump --db test
mongorestore --db test1 dump/test/
Failed: test1.contacts: error creating collection test1.contacts: error running create command: $regex has to be a string
I have a trouble while restoring db with collection that contains regex in validator in MongoDB 3.2.3.
Hi,
This $regex issue should be fixed in MongoDB v3.2.4+ (mongorestore).
Also, worth mentioning that the latest stable release for MongoDB v3.2.x is version 3.2.11. See also Upgrade to the Latest Revision of MongoDB
Kind regards,
Wan.