Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
fix the updateDocument function. previously the id and revision were …
Browse files Browse the repository at this point in the history
…not being used causing a conflict error. now the id and rev from the previous document are added to the new and saved
  • Loading branch information
nraboy committed Jan 4, 2017
1 parent 823d5a0 commit f2c39ad
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
7 changes: 5 additions & 2 deletions couchbase.android.ts
Expand Up @@ -37,8 +37,11 @@ export class Couchbase {
return JSON.parse(this.mapToJson(document.getProperties()));
}

updateDocument(documentId: string, data: Object) {
var document: any = this.database.getDocument(documentId);
updateDocument(documentId: string, data: any) {
let document: any = this.database.getDocument(documentId);
let temp: any = JSON.parse(this.mapToJson(document.getProperties()));
data._id = temp._id;
data._rev = temp._rev;
try {
document.putProperties(this.objectToMap(data));
} catch (exception) {
Expand Down
2 changes: 1 addition & 1 deletion couchbase.d.ts
Expand Up @@ -4,7 +4,7 @@ declare module "nativescript-couchbase" {
constructor(databaseName: string);
createDocument(data: Object, documentId?: string);
getDocument(documentId: string);
updateDocument(documentId: string, data: Object);
updateDocument(documentId: string, data: any);
deleteDocument(documentId: string);
destroyDatabase();
createView(viewName: string, viewRevision: string, callback: any);
Expand Down
6 changes: 4 additions & 2 deletions couchbase.ios.ts
Expand Up @@ -49,9 +49,11 @@ export class Couchbase {
return null;
}

updateDocument(documentId: string, data: Object){
updateDocument(documentId: string, data: any){
var document = this.database.documentWithID(documentId);

let temp: any = this.getDocument(documentId);
data._id = temp._id;
data._rev = temp._rev;
var errorRef = new interop.Reference();
var revision = document.putPropertiesError(data, errorRef);

Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Expand Up @@ -24,4 +24,4 @@
"nativescript-dev-typescript": "^0.3.2",
"typescript": "^2.0.3"
}
}
}
Binary file removed dist/nativescript-couchbase-1.0.11.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion ng-demo/package.json
Expand Up @@ -36,4 +36,4 @@
"typescript": "^2.0.3",
"zone.js": "^0.6.21"
}
}
}
7 changes: 5 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "nativescript-couchbase",
"version": "1.0.14",
"version": "1.0.15",
"description": "Couchbase Lite plugin for Telerik NativeScript",
"main": "couchbase.js",
"nativescript": {
Expand Down Expand Up @@ -33,6 +33,9 @@
"nosql",
"nativescript"
],
"author": "Nic Raboy",
"author": {
"name": "Nic Raboy",
"url": "https://www.thepolyglotdeveloper.com"
},
"license": "Apache-2.0"
}

0 comments on commit f2c39ad

Please sign in to comment.