| {% include anchor.html edit="true" title="Get database information" hash="database_information" %} |
| |
| {% highlight js %} |
| db.info([callback]) |
| {% endhighlight %} |
| |
| Get information about a database. |
| |
| #### Example Usage: |
| |
| {% include code/start.html id="dbinfo" type="callback" %} |
| {% highlight js %} |
| db.info(function(err, info) { |
| if (err) { return console.log(err); } |
| // handle result |
| }); |
| {% endhighlight %} |
| {% include code/end.html %} |
| |
| {% include code/start.html id="dbinfo" type="async" %} |
| {% highlight js %} |
| try { |
| var result = await db.info(); |
| } catch (err) { |
| console.log(err); |
| } |
| {% endhighlight %} |
| {% include code/end.html %} |
| |
| {% include code/start.html id="dbinfo" type="promise" %} |
| {% highlight js %} |
| db.info().then(function (result) { |
| // handle result |
| }).catch(function (err) { |
| console.log(err); |
| }); |
| {% endhighlight %} |
| {% include code/end.html %} |
| |
| #### Example Response: |
| {% highlight js %} |
| { |
| "db_name": "test", |
| "doc_count": 4, |
| "update_seq": 5 |
| } |
| {% endhighlight %} |
| |
| **Response object:** |
| |
| * `db_name` is the name of the database you gave when you called `new PouchDB()`, and also the unique identifier for the database. |
| * `doc_count` is the total number of non-deleted documents in the database. |
| * `update_seq` is the sequence number of the database. It starts at 0 and gets incremented every time a document is added or modified. |
| |
| There are also some details you can use for debugging. These are unofficial and may change at any time: |
| |
| * `adapter`: The name of the adapter being used (idb, websql, leveldb, ...). |
| * `idb_attachment_format`: (IndexedDB) either `'base64'` or `'binary'`, depending on whether the browser [supports binary blobs](/faq.html#data_types). |
| * `sqlite_plugin`: (WebSQL) true if the [SQLite Plugin][] is being used. |
| * `websql_encoding`: (WebSQL) either `'UTF-8'` or `'UTF-16'`, depending on the [WebSQL implementation](http://pouchdb.com/faq.html#data_types) |
| * `backend_adapter`: (Node.JS) the backend *DOWN adapter being used (MemDOWN, RiakDOWN, ...). |