Optional
maxThe maximum time to wait for a response from the server, in milliseconds.
Optional
nameIf true, only the name of the collection is returned.
If false, the full collection info is returned.
Defaults to true.
const names = await db.listCollections({ nameOnly: true });
console.log(names); // [{ name: 'my-coll' }]
const info = await db.listCollections({ nameOnly: false });
console.log(info); // [{ name: 'my-coll', options: { ... } }]
true
Optional
namespaceThe namespace (aka keyspace) to use for the db operation.
Options for listing collections.
Field
nameOnly - If true, only the name of the collection is returned. If false, the full collection info is returned. Defaults to true.
Field
namespace - Overrides the namespace to list collections from. If not provided, the default namespace is used.
Field
maxTimeMS - The maximum amount of time to allow the operation to run.
See
Db.listCollections