Skip to content

Commit d32595f

Browse files
committed
DEVEXP-587 : Update README to include an example for connecting to MarkLogic Cloud
1 parent f9acc2b commit d32595f

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ collection into the Documents database using MarkLogic's built-in REST server
3737
at port 8000:
3838

3939
```javascript
40-
var marklogic = require('marklogic');
40+
const marklogic = require('marklogic');
4141

42-
var db = marklogic.createDatabaseClient({
42+
const db = marklogic.createDatabaseClient({
4343
host: 'localhost',
4444
port: '8000',
4545
database: 'Documents',
@@ -48,6 +48,17 @@ var db = marklogic.createDatabaseClient({
4848
authType: 'DIGEST'
4949
});
5050

51+
// For MarkLogic Cloud
52+
const db = marklogic.createDatabaseClient({
53+
apiKey: 'changeme',
54+
host: 'example.beta.marklogic.com',
55+
authType: 'cloud',
56+
// basePath is optional.
57+
basePath: '/marklogic/test',
58+
// accessTokenDuration (in seconds) is optional and can be used to customize the expiration of the access token.
59+
accessTokenDuration: 10
60+
});
61+
5162
db.createCollection(
5263
'/books',
5364
{author: 'Beryl Markham', ...},

examples/marklogic-cloud-connection.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ and writes a document in database - Documents */
1919

2020
const marklogic = require('../');
2121

22-
let db = marklogic.createDatabaseClient({
22+
const db = marklogic.createDatabaseClient({
2323
// The below key-value pairs are required
24-
apiKey: 'apiKey',
25-
host: 'example.marklogic.com',
24+
apiKey: 'changeme',
25+
host: 'example.beta.marklogic.com',
2626
authType: 'cloud',
27-
basePath: 'basePath',
28-
// accessTokenDuration is optional and can be used to customize the expiration of the access token.
27+
// basePath is optional.
28+
basePath: '/marklogic/test',
29+
// accessTokenDuration (in seconds) is optional and can be used to customize the expiration of the access token.
2930
accessTokenDuration: 10
3031
});
3132

32-
let writeObject = {
33+
const writeObject = {
3334
uri: '/write/string1.json',
3435
contentType: 'application/json',
3536
content: '{"key1":"value 1"}'

0 commit comments

Comments
 (0)