CAST supports MarkLogic via its Node.js extension. Details about how this support is provided for .Node.js source code is discussed below.
Objects
The following specific objects are displayed in CAST Enlighten:
Icon | Description |
---|---|
Node.js Marklogic Database | |
Node.js Marklogic Collection |
Code samples
This declaration will create a MarkLogic database and a collection:
Connector "marklogic"
var db = marklogic.createDatabaseClient(conn); // create Collection countries var q = marklogic.queryBuilder; db.documents.query( q.where( q.collection('countries'), q.value('region', 'Africa'), q.or( q.word('background', 'France'), q.word('Legal system', 'French') ) ) ).result(function(documents) { documents.forEach(function(document){ console.log(JSON.stringify(document)); }); });
This declaration will create a MarkLogic collection "fake data" and a useDeleteLink to the collection "fake data":
db.documents.removeAll({collection: 'fake data'}) .result() .then(response => console.log('Removed collection ' + response.collection)) .catch(error => console.log(error));
This declaration will create a MarkLogic collection "fake data" and a useInsertLink to the collection "fake data":
db.documents.write( data.map((item) => { return { uri: `/${item.guid}.json`, contentType: 'application/json', collections: ['fake data'], content: item } }) ) .result() .then(response => console.dir(JSON.stringify(response))) .catch(error => console.error(error));