Marklogi c node js клиентский API не подключается к базе данных - PullRequest
1 голос
/ 04 февраля 2020

Я пытаюсь загрузить некоторые документы в базу данных «Документы», но получаю эту ошибку при загрузке узла. js (имя файла):

Ошибка: чтение ECONNRESET в TCP. onStreamRead (internal / stream_base_commons. js: 201: 27) {errno: -4077, код: 'ECONNRESET', системный вызов: 'read'}

load.js

  // Load documents into the database.

const marklogic = require('marklogic');
const my = require('./my-connection.js');
const db = marklogic.createDatabaseClient(my.connInfo);

// Document descriptors to pass to write(). 
const documents = [
  { uri: '/gs/aardvark.json',
    content: {
      name: 'aardvark',
      kind: 'mammal',
      desc: 'The aardvark is a medium-sized burrowing, nocturnal mammal.'
    }
  },
  { uri: '/gs/bluebird.json',
    content: {
      name: 'bluebird',
      kind: 'bird', 
      desc: 'The bluebird is a medium-sized, mostly insectivorous bird.'
    }
  },
  { uri: '/gs/cobra.json',
    content: {
      name: 'cobra',
      kind: 'mammal',
      desc: 'The cobra is a venomous, hooded snake of the family Elapidae.'
    }
  },
];

// Load the example documents into the database
db.documents.write(documents).result( 
  function(response) {
    console.log('Loaded the following documents:');
    response.documents.forEach( function(document) {
      console.log('  ' + document.uri);
    });
  }, 
  function(error) {
    console.log(JSON.stringify(error, null, 2));
  }
);

my-connection.js

module.exports = {
  connInfo: {
    host: 'localhost',
    port: 8000,
    user: 'user',
    password: 'password'
  }
};
...