Lo2 Nosql2
Lo2 Nosql2
b. Rename Collections
To rename a collection, you can use the renameCollection
method.
Eg:
db.myCollection.renameCollection("newCollectionName
")
Example Workflow
// Step 1: Create a new database and collection
o use myDatabase
o db.createCollection("myCollection")
o db.myCollection.insertOne({ name: "Alice", age: 25 })
Listing Indexes:
o To view the indexes on a collection, use
the getIndexes() method