new PouchDB( [dbName])
Create a new simple JSON document store using PouchDB.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
dbName |
string |
<optional> |
The name of the database store to create/open, defaults to 'DocumentStore'. |
Members
-
:object
currentDoc
-
Stores information about the current document.
Type
- object
-
:string
dbName
-
The name of the database store.
Type
- string
-
:string
dbServer
-
The URL of the remote CouchDB server, if any.
Type
- string
-
dbSize
-
The maximum size of the database in MB.
-
:boolean
isPouchDB <readonly>
-
A flag indicating that this object is a custom PouchDB wrapper instance.
Type
- boolean
-
:PouchDB|null
localDB
-
The local PouchDB database connection.
Type
- PouchDB | null
-
:string
password
-
The password for authentication.
Type
- string
-
:PouchDB|null
remoteDB
-
The remote PouchDB database connection.
Type
- PouchDB | null
-
:string
username
-
The username for authentication.
Type
- string
Methods
-
delete(id) <async>
-
Deletes a document from the database.
Parameters:
Name Type Description idstring The database key associated with the document to remove.
Returns:
Returns
trueif the document was successfully deleted, otherwisefalse.- Type
- boolean
-
dispose() <async>
-
Disposes of the database and frees resources.
Returns:
Returns
trueif the database was successfully destroyed.- Type
- boolean
-
get(id) <async>
-
Retrieve a document from the database.
Parameters:
Name Type Description idstring The database key associated with a document.
Returns:
Returns the document if found, otherwise null.
- Type
- object | null
-
keys() <async>
-
Retrieves a list of keys for documents in the database.
Returns:
Returns an array of document keys.
- Type
- Array.<string>
-
open() <async>
-
Open the database and create the object store if it doesn't exist.
Returns:
Returns
trueif the database was opened successfully, otherwisefalse.- Type
- boolean
-
rename(oldId, newId) <async>
-
Renames a document in the database.
Parameters:
Name Type Description oldIdstring The current ID of the document.
newIdstring The new ID to assign to the document.
Returns:
Returns
trueif the document was successfully renamed.- Type
- boolean
-
save(data) <async>
-
Saves the last loaded document to the database.
Parameters:
Name Type Description dataobject The document to store in the database.
Returns:
Returns
trueif the document was successfully saved.- Type
- boolean
-
saveAs(id, json) <async>
-
Saves a document to the database with a different name.
Parameters:
Name Type Description idstring The new database key to associate with the document.
jsonobject The JSON object to store in the database.
Returns:
Returns
trueif the document was successfully saved.- Type
- boolean
-
set(id, data) <async>
-
Saves a document to the database with the given name.
Parameters:
Name Type Description idstring The new database key to associate with the document.
dataobject The JSON object or string to store in the database.
Returns:
Returns
trueif the document was successfully saved, otherwisefalse.- Type
- boolean
-
isSupported() <static>
-
Checks if the browser/client supports PouchDB.
Returns:
Returns
trueif PouchDB is supported, otherwisefalse.- Type
- boolean