bdkdavid
bdkdavid

Reputation: 223

Marklogic error taken from sample documents

'use strict'; declareUpdate();
 const es = require('/MarkLogic/entity-services/entity-services.xqy');
 const person = require('/es-gs/person-1.0.0-conv.xqy');
for (const source of fn.collection('raw')) {
  let instance = person.extractInstancePerson(source);
  let uri = '/es-gs/env/' + instance.id + '.xml';
  xdmp.documentInsert(
    uri, person.instanceToEnvelope(instance, "xml"),
    {collections: ['person-envelopes']}
  );
}

I have taken the following code from the marklogic web page link to site

I am getting the following error. I am following the directions step by step any ideas

[javascript] XDMP-MODNOTFOUND: const person = require('/es-gs/person-1.0.0-conv.xqy');
 -- Module /es-gs/person-1.0.0-conv.xqy not found
Stack Trace
 At line 4 column 15:

I have the /es-gs/person-1.0.0-conv.xqy it exist

Site here

Upvotes: 1

Views: 75

Answers (1)

Mads Hansen
Mads Hansen

Reputation: 66714

Is it possible that when you deployed the converter module you accidentally loaded the converter module into the content database, instead of the modules database?

Like any application code, the converter module must be deployed to MarkLogic before you can use it. Best practice is to install it in the modules database of your App Server. Our example uses the pre-defined App Server on port 8000, which is configured to use the Modules database.

  1. Open Query Console in your browser if you do not already have it open.
  2. Add a new query to the workspace by clicking on the + button on the query editor.
  3. Select XQuery in the Query Type dropdown.
  4. Select the Modules database from the Database dropdown.
  5. Copy and paste the following code into the new query. This code saves the instance converter module to the database.

I actually just made that mistake and skipped step 4 when attempting to reproduce your issue! Once I loaded it into my Modules database, the require statement can find and load the module without error.

Upvotes: 1

Related Questions