Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1896935

Browse files
committedApr 7, 2015
Merge branch 'develop'
2 parents d6a13f8 + da2aad8 commit 1896935

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4795
-1775
lines changed
 

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from Node.js applications.
1414

1515
## Status
1616

17-
Release 1.0.0 of the MarkLogic Node.js API
17+
Release 1.0.2 of the MarkLogic Node.js API
1818

1919
## Sample
2020

@@ -56,7 +56,7 @@ Other calls can create additional documents for the same collection.
5656

5757
Here are some resources that walk you through working with MarkLogic using the Node.js API:
5858

59-
* http://developer.marklogic.com/features/node-api
59+
* http://developer.marklogic.com/features/node-client-api
6060
* http://docs.marklogic.com/guide/node-dev/intro#id_68052
6161

6262
The instructions describe:

‎examples/optimistic-locking.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var exutil = require('./example-util.js');
1818
//a real application would require without the 'exutil.' namespace
1919
var marklogic = exutil.require('marklogic');
2020

21-
var p = marklogic.patchBuilder;
21+
var pb = marklogic.patchBuilder;
2222

2323
var dbAdmin = marklogic.createDatabaseClient(exutil.restAdminConnection);
2424

@@ -28,48 +28,48 @@ var timestamp = (new Date()).toISOString();
2828

2929
var uri = '/countries/uv.json';
3030
var operations = [
31-
p.pathLanguage('jsonpath'),
32-
p.replaceInsert('$.timestamp', '$.name', 'after', timestamp)
31+
pb.pathLanguage('jsonpath'),
32+
pb.replaceInsert('$.timestamp', '$.name', 'after', timestamp)
3333
];
3434

3535
console.log('configure the server to enforce optimistic locking');
3636
// a one-time administrative action
3737
dbAdmin.config.serverprops.write({
3838
'update-policy': 'version-required'
39-
}).
40-
result(function(response) {
39+
})
40+
.result(function(response) {
4141
console.log(
4242
'try to update a value in the content to '+
4343
timestamp+'\n without passing the document version id');
4444
db.documents.patch({
4545
uri: uri,
4646
operations: operations
4747
// versionId not specified
48-
}).result(
49-
function(success) {
50-
console.log('should never execute');
51-
},
52-
function(failure) {
53-
console.log('expected failure for the update without the version id');
48+
})
49+
.result(function(success) {
50+
console.log('should never execute');
51+
})
52+
.catch(function(failure) {
53+
console.log('expected failure for the update without the version id');
5454

55-
console.log('get the current version id for the document');
56-
db.documents.probe(uri).result().
57-
then(function(document){
55+
console.log('get the current version id for the document');
56+
db.documents.probe(uri)
57+
.result(function(document){
5858
console.log(
5959
'try to update the document passing the version id '+document.versionId);
6060
return db.documents.patch({
6161
uri: uri,
6262
operations: operations,
6363
versionId: document.versionId
6464
}).result();
65-
}).
66-
then(function(response){
65+
})
66+
.then(function(response){
6767
console.log('update succeeded with the version id');
6868

6969
console.log('get the new version id for the updated document');
7070
return db.documents.read(uri).result();
71-
}).
72-
then(function(documents) {
71+
})
72+
.then(function(documents) {
7373
var document = documents[0];
7474
console.log(
7575
'the document has the new version id '+document.versionId+
@@ -81,19 +81,21 @@ dbAdmin.config.serverprops.write({
8181
return dbAdmin.config.serverprops.write({
8282
'update-policy': 'merge-metadata'
8383
}).result();
84-
}).
85-
then(function(response) {
86-
console.log('done');
84+
})
85+
.then(function(response) {
86+
console.log('done');
8787

88-
exutil.succeeded();
89-
}, function(error) {
90-
console.log(JSON.stringify(error));
88+
exutil.succeeded();
89+
})
90+
.catch(function(error) {
91+
console.log(JSON.stringify(error));
9192

92-
exutil.failed();
93-
});
93+
exutil.failed();
94+
});
9495
});
95-
}, function(error) {
96+
})
97+
.catch(function(error) {
9698
console.log(JSON.stringify(error));
9799

98100
exutil.failed();
99-
});
101+
});

0 commit comments

Comments
 (0)
Please sign in to comment.