File: commands.md

package info (click to toggle)
node-mongodb 3.6.4%2B~cs11.13.19-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 76,604 kB
  • sloc: javascript: 138,083; python: 429; sh: 52; makefile: 37
file content (36 lines) | stat: -rw-r--r-- 925 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+++
date = "2015-03-19T14:27:51-04:00"
title = "Database Commands"
[menu.main]
  parent = "Tutorials"
  identifier = "Database Commands"
  weight = 70
  pre = "<i class='fa'></i>"
+++

# Database Commands

Database commands allow you to perform a wide range of diagnostic and administrative
tasks with the Node.js driver. For example, the
[dbStats](https://docs.mongodb.org/manual/reference/command/dbStats/) command returns
storage statistics for a given database. Use the ``command`` function to access
database commands.

```js
// set up a command function
function getDbStats(db, callback) {
  db.command({'dbStats': 1}, function(err, results) {
    console.log(results);
    callback();
  });
};

// use the function
{{% myproject-connect %}}
  getDbStats(db, function() {
    client.close();
  });
});
```

For a complete list of database commands, see the [manual](https://docs.mongodb.org/manual/reference/command/).