javascript - 使用 node.js 连接到 ravendb

标签 javascript node.js ravendb ravendb4

我目前正在尝试使用node.js 和ravendb 建立一个小项目。但是当我尝试连接到 ravendb 测试服务器或本地服务器时,出现以下错误:

(node:20336) UnhandledPromiseRejectionWarning: AllTopologyNodesDownException: Tried to send BatchCommand request via POST http://live-test.ravendb.net/databases/Northwind/bulk_docs to all configured nodes in the topology, all of them seem to be down or not responding. I've tried to access the following nodes: http://live-test.ravendb.net: socket hang up
at getError (C:\...\node_modules\ravendb\dist\Exceptions\index.js:17:19)
at Object.throwError (C:\...\node_modules\ravendb\dist\Exceptions\index.js:13:11)
at RequestExecutor._throwFailedToContactAllNodes (C:\...\node_modules\ravendb\dist\Http\RequestExecutor.js:669:22)
at RequestExecutor.<anonymous> (C:\...\node_modules\ravendb\dist\Http\RequestExecutor.js:573:26)
at Generator.next (<anonymous>)
at fulfilled (C:\...\node_modules\ravendb\dist\Http\RequestExecutor.js:4:58)
at process._tickCallback (internal/process/next_tick.js:68:7) 
(node:20336) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). 
(rejection id: 1) 
(node:20336) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

索引.js

const { DocumentStore } = require('ravendb');

const store = new DocumentStore("http://live-test.ravendb.net", "Northwind");

store.initialize();   

const session = store.openSession();

async function asyncFunction() {
    let test = {
        name: 'abc',
        value: '123',
    };

    await session.store(test, 'test/');
    console.log(test.id);
    await session.saveChanges();
}

asyncFunction()

store.dispose();

package.json

{
  "dependencies": {
    "ravendb": "^4.1.5"
  }
}

最佳答案

尝试这样:

import { DocumentStore } from "ravendb";

const store = new DocumentStore(["http://live-test.ravendb.net"],"Northwind");                       

const conventions = store.conventions;  

store.initialize();  

关于javascript - 使用 node.js 连接到 ravendb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56397926/

相关文章:

javascript - 如何从对象元素中获取没有重复的数组

javascript - express res.download()

javascript - Node/Electron 中的暗模式检测

javascript - 错误 : Missing helper: "if_equal" handlebars

ravendb - 增加 RavenDb 中的文档属性

mysql - 从 SQL 导入 RavenDB Northwind - 为什么没有给 employee_privileges 一个集合?

php - 有没有比将它放在 PHP 数组中更好的方法来隐藏和存储 JQuery/JavaScript 应用程序的只读数据?

javascript - 如何使用express处理路由器中连续的两个斜杠?

indexing - RavenDB:排序、索引和投影

javascript - 在移动 View 中显示子链接