mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 16:52:53 +08:00
docs(couchbase-lite): update usage (#2059)
* adding detailed usage for couchbase lite * added get url method * create database method added * delete database method added * get all database method added * space added in comments * comments added unwanted import removed * whitespaces added * usage added in commented section * get all documents,create document methods added * spell mistake corrected * getAllDocs Method Usage added * create document example added * update document example added * delete document example added
This commit is contained in:
parent
b9b781ddee
commit
38bbf01e8c
@ -45,7 +45,6 @@ import { Injectable } from '@angular/core';
|
||||
* return Observable.throw(error.json() || 'Couchbase Lite error');
|
||||
* })
|
||||
* }
|
||||
*
|
||||
* getAllDbs() {
|
||||
* let url = this.getUrl();
|
||||
* url = url+'_all_dbs';
|
||||
@ -56,6 +55,59 @@ import { Injectable } from '@angular/core';
|
||||
* return Observable.throw(error.json() || 'Couchbase Lite error');
|
||||
* })
|
||||
* }
|
||||
* // DOCUMENTS //
|
||||
* getAllDocuments(database_name:string){
|
||||
* let url = this.getUrl();
|
||||
* // include_docs=true will include a doc inside response, it is false by default
|
||||
* url = url + database_name + '/_all_docs?include_docs=true';
|
||||
* return this._http
|
||||
* .get(url)
|
||||
* .map(data => { this.results = data['results'] })
|
||||
* .catch((error:any) => {
|
||||
* return Observable.throw(error.json() || 'Couchbase Lite error');
|
||||
* }) .
|
||||
* }
|
||||
* createDocument(database_name:string,document){
|
||||
* let url = this.getUrl();
|
||||
* url = url + database_name;
|
||||
* return this._http
|
||||
* .post(url,document)
|
||||
* .map(data => { this.results = data['results'] })
|
||||
* .catch((error:any) => {
|
||||
* return Observable.throw(error.json() || 'Couchbase Lite error');
|
||||
* }) .
|
||||
* }
|
||||
* let document = {
|
||||
* _id:'You can either specify the document ID (must be string) else couchbase generates one for your doc',
|
||||
* data:{name:'sandman',age:25,city:pune}
|
||||
* }
|
||||
* createDocument('justbe', document);
|
||||
* // successful response
|
||||
* { "id": "string","rev": "string","ok": true }
|
||||
* updateDocument(database_name:string,document){
|
||||
* let url = this.getUrl();
|
||||
* url = url + database_name + '/' + document._id;
|
||||
* return this._http
|
||||
* .put(url,document)
|
||||
* .map(data => { this.results = data['results'] })
|
||||
* .catch((error:any) => {
|
||||
* return Observable.throw(error.json() || 'Couchbase Lite error');
|
||||
* }) .
|
||||
* }
|
||||
* // for updation of document your document must contain most recent rev(revision) id.
|
||||
* // for each updation of document new rev id is get generated
|
||||
* // successful response
|
||||
* { "id": "string","rev": "string(new revision id)","ok": true }
|
||||
* deleteDocument(database_name:string,document){
|
||||
* let url = this.getUrl();
|
||||
* url = url + database_name + '/' + document._id +'?rev='+doc._rev;
|
||||
* return this._http
|
||||
* .delete(url)
|
||||
* .map(data => { this.results = data['results'] })
|
||||
* .catch((error:any) => {
|
||||
* return Observable.throw(error.json() || 'Couchbase Lite error');
|
||||
* }) .
|
||||
* }
|
||||
*
|
||||
*
|
||||
* ```
|
||||
|
Loading…
Reference in New Issue
Block a user