MongoDB Rename Collection Use db.collection.renameCollection() method to rename existing collection in MongoDB database. Syntax: db.collection.renameCollection(target, dropTarget) Example: For example, You have a collection with wrong spelling “pproducts“. Let’s use the following command on mongo Shell to correct collection name to “products“. db.pproducts.renameCollection(“products”) Output: { “ok” : 1 }
Read MoreTag: Collection
MongoDB – Show Collection
Mongodb Show Collection Use show collections command from MongoDB shell to list all collections created in the current database. First, select the database you want to view the collection. Mongodb Show Collection Select your database and run show collections command to list available collections in MongoDB database. > use mydb > show collections Output: TECADMIN accounts mycol pproducts users Get Collections Information To find detailed information about the database collections use .getCollectionInfos() function. This will provide an array of documents with collection information, such as name and options. > db.getCollectionInfos();…
Read More