C# Java
Article For
4.0 4.1 4.2 5.1 5.2 5.3

Client API: How to Create a Document Store

To create an instance of the DocumentStore you need to specify a list of URL addresses that point to RavenDB server nodes.

new DocumentStore(urls, [database], [authOptions]);


Do not open a DocumentStore using URL addresses that point to nodes outside your cluster.

const store = new DocumentStore(["http://localhost:8080"], "Northwind");

The above snippet is going to instantiate a communication channel between your application and the local RavenDB server instance.


A DocumentStore instance must be initialized before use by calling the .initialize() method.


After DocumentStore initialization, the conventions are frozen - modification attempts are going to result with error. Conventions need to be set before .initialize() is called.


Because the document store is a heavyweight object, there should only be one instance created per application (a singleton - simple to achieve in Node.js by wrapping it in a module). Typical initialization of a document store looks as follows:

// documentStoreHolder.js
const store = new DocumentStore("http://localhost:8080", "Northwind");
export { store as documentStore }; 


If you use more than one instance of DocumentStore, you should dispose it after use by calling its .dispose() method.