Skip to content

Commit d741aad

Browse files
committed
NODE-122 : Add an example for ML Cloud connection
1 parent c0928f7 commit d741aad

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2023 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/* This file provides an example for the users to help them connect to MarkLogic cloud using the apiKey and host
18+
and writes a document in database - Documents */
19+
20+
const marklogic = require('../');
21+
22+
let db = marklogic.createDatabaseClient({
23+
// All the below key-value pairs are required
24+
apiKey: 'apiKey',
25+
host: 'example.marklogic.com',
26+
authType: 'cloud',
27+
basePath: 'basePath'
28+
});
29+
30+
let writeObject = {
31+
uri: '/write/string1.json',
32+
contentType: 'application/json',
33+
content: '{"key1":"value 1"}'
34+
};
35+
db.documents.write(writeObject)
36+
.result(function(){})
37+
.then(function() {
38+
marklogic.releaseClient(db);
39+
})
40+
.catch(err => {throw new Error(err);});

0 commit comments

Comments
 (0)