MongoDB alias on collection name?

Viewed 437

Is it possible to add an alias on mongodb collection name, so the reference in the code doesn't need to be changed? Lets say I have a collection named test-foo and I need to change it in testFoo, is there a way to add an alias so the reference in code stays the same? Thanks!

1 Answers

No, synomyms are not supported. You could use variables:

var t = "test-Foo";
db.getCollection(t).find({});

Then your code can be more generic.

Related