Viet Hoang
Viet Hoang

Reputation: 124

Connect to RavenDB using nodejs

I am using node to connect to RavenDB https://www.npmjs.com/package/ravendb
but when try to create a connection, at this step https://i.sstatic.net/fcFZ9.png
I dont know what to put in database url and default database name and I put
database url=localhost:5000
default database name=test (my db name is test)

and the console show this error Failed to load http://localhost:5000/topology?name=test how can I create this connection.

EDIT I config the program
this is my file app.js
const DocumentStore = require('ravendb').default; const store = DocumentStore.create('localhost:5000', 'test'); store.initialize(); const session = store.openSession();


when I run this file with node, it show the error: (but it will compile fine if I delete the line
const session = store.openSession(); so I think the problem is somewhere around the session.
Error log:

"C:\Program Files\JetBrains\WebStorm 2017.2\bin\runnerw.exe" D:\nodejs\node.exe D:\nodeProject\demoraven\app.js Unhandled rejection ee: Node localhost:5000 is down at d.finally.catch.e (D:\nodeProject\demoraven\node_modules\ravendb\lib\ravendb-node.js:2:52762) at tryCatcher (D:\nodeProject\demoraven\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (D:\nodeProject\demoraven\node_modules\bluebird\js\release\promise.js:512:31) at Promise._settlePromise (D:\nodeProject\demoraven\node_modules\bluebird\js\release\promise.js:569:18) at Promise._settlePromise0 (D:\nodeProject\demoraven\node_modules\bluebird\js\release\promise.js:614:10) at Promise._settlePromises (D:\nodeProject\demoraven\node_modules\bluebird\js\release\promise.js:689:18) at Async._drainQueue (D:\nodeProject\demoraven\node_modules\bluebird\js\release\async.js:133:16) at Async._drainQueues (D:\nodeProject\demoraven\node_modules\bluebird\js\release\async.js:143:10) at Immediate.Async.drainQueues (D:\nodeProject\demoraven\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5)

Upvotes: 0

Views: 928

Answers (2)

UchihaItachi
UchihaItachi

Reputation: 2752

as @Judah Himango said , you can test whether your code is able to connect to revendb database using url provided by him .

I think you are using the wrong port to connect to ravendb , i.e you should set database url=localhost:8080 instead of localhost:5000 as the default port of ravendb is 8080

Upvotes: 0

Judah Gabriel Himango
Judah Gabriel Himango

Reputation: 60061

I dont know what to put in database url and default database name and I put

Database URL is the HTTP address where you're running a Raven Server. You can download Raven and run it locally. Or if you're just testing, you can connect to the playground server located at http://4.live-test.ravendb.net

For DefaultDatabase, that's the database you want to connect to. If you already have created a database, use that name. Otherwise, put in any name, and it will be created for you.

So, to sum up, your code should look like this:

const dbUrl = "http://4.live-test.ravendb.net"; // Alternately, if you're running Raven Server locally, use http://localhost:8080 
const store = DocumentStore.create(dbUrl, "MyTestingDatabase");
store.initialize();

Upvotes: 1

Related Questions