You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Creates a database without HTTP server or replicators. * IMPORTANT: If succeed, the promise is resolve returning an empty value. * IMPORTANT: If failed, the promise is rejected returning the error. * @param database String Database name. * @param promise Promise Promise to be returned to the JavaScript engine. */publicvoidcreateDatabase(Stringdatabase, Promisepromise)
Destroy database.
/** * Destroys an existing database (also stops replicators). * IMPORTANT: If succeed, the promise is resolve returning an empty value. * IMPORTANT: If failed, the promise is rejected returning the error. * @param database String Database name. * @param promise Promise Promise to be returned to the JavaScript engine. */publicvoiddetroyDatabase(Stringdatabase, Promisepromise)
Retrieving data
Get document.
/** * Gets an existing document from the database. * @param database String Database name. * @param docId String Document id. * @param promise Promise Promise to be returned to the JavaScript engine. */publicvoidgetDocument(Stringdatabase, StringdocId, Promisepromise)
Get all documents.
/** * Gets all the existing documents from the database. * @param database String Database name. * @param docIds ReadableArray JavaScript array containing the keys. * @param promise Promise Promise to be returned to the JavaScript engine. */publicvoidgetAllDocuments(Stringdatabase, RedeableArraydocIds, Promisepromise)
Get view.
/** * Gets all the documents returned by the given view. * @param database String Database name. * @param design String Design document where the view can be found. * @param viewName String Name of the view to be queried. * @param params ReadableMap JavaScript object containing the extra parameters to pass to the view. * @param docIds ReadableArray JavaScript array containing the keys. * @param promise Promise Promise to be returned to the JavaScript engine. */publicvoidgetView(Stringdatabase, Stringdesign, StringviewName, ReadableMapparams, ReadableArraydocIds, Promisepromise)
Storing data
Put document.
/** * Creates/Updates a document. * @param database String Database name. * @param docId String Document id. * @param params ReadableMap Javascript object containing document data. * @param promise Promise Promise to be returned to the JavaScript engine. */publicvoidputDocument(Stringdatabase, StringdocId, ReadableMapparams, Promisepromise)
Useful Functions
Close Database and Stop Replicators
Useful if you want to stop replicators (needed for destroying database through REST API)
/** * IMPORTANT: This function is only available in IOS * Close Database and Replicators * @param database string name of database * @param onEnd Callback function to call when finish */CouchBase.closeDatabase(stringdatabase, CallbackonEnd)
Compact an existing local database
/** * compacts an already created local database * @param databaseLocal String database for local server */publicvoidcompact(StringdatabaseLocal)
Set timeout for PULL and PUSH replicators (ONLY iOS)
/** * IMPORTANT: This function is only available in IOS * Set timeout for pull or push requests * @param timeout integer timeout for requests in ms */CouchBase.setTimeout(integertimeout)
Resfresh PUSH replicators (ONLY Android)
/** * IMPORTANT: This function is only available in Android * Used to triggers events like not existing Database after replaction started. * @param database string name of database */CouchBase.refreshReplication(StringdatabaseLocal)
Enable debug log
/** * Enable debug log for CBL * @param debug_mode boolean debug module for develop: true for VERBOSE log, false for Default log level. */CouchBase.enableLog(booleandebug_mode)