-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how do I do "show collections" in mongojs code? #54
Comments
While var mongojs = require('mongojs');
var db = mongojs('test', []);
db.collections(function(e, cols) {
cols.forEach(function(col) {
console.log(col.collectionName);
});
}); I hope this helps :) |
There is something called getCollectionNames() in the docs. Would be nice to see it in mongojs as well, not a big deal though. |
db.getCollectionNames() has been added in 0.7.12 (see #73) |
Thanks all. |
Am I missing something or is this currently (mongojs 0.13.1) broken?
|
@mb21 You have to pass a callback to the db.getCollectionNames(function(err, colNames) {
if (err) return console.log(err);
colNames.forEach(function(name) {
console.log(name);
});
}); |
@mb21 Good point. Will fix. |
db.getCollectionNames(function(err, colNames) { This will just list the collections, which is already using inside the mongojs call // var db = mongojs(connectionString, [collections] // Use the admin database for the operation // List all the available databases |
Mongo db shell support "show collections" to list all the collections of a database.
How do I do this in javascript using mongojs?
The text was updated successfully, but these errors were encountered: