Skip to content

Instantly share code, notes, and snippets.

@vmetnev
Created April 8, 2024 16:40
Show Gist options
  • Save vmetnev/c01b4cf78ef8f4274abc5ebe58dace77 to your computer and use it in GitHub Desktop.
Save vmetnev/c01b4cf78ef8f4274abc5ebe58dace77 to your computer and use it in GitHub Desktop.
List Mongoose Connections
mongooseConnect();
async function listCollections() {
let db = mongoose.connection.db;
const collections = await db.listCollections().toArray();
collections.forEach((collection) => console.log(collection.name));
db = mongoose.connection.db;
await db.collection("popcorn").rename("popcorn1").catch(error=>console.log(error.codeName))
mongoose.disconnect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment