Getting started with RavenDB



Setup (Windows)

Creating a database in RavenDB

Building a simple CRUD.

var store = new DocumentStore{Urls = new[] {"https://localhost:8080"},Database = "Game"};store.Initialize();
public class Characters{public string Id { get; set; }public string Name { get; set; }public string Faction { get; set; }public string Power { get; set; }public int Level { get; set; }public bool Pet { get; set; }}
using (var session = store.OpenSession()){var character = new Characters{Name = "Milan",Faction = "Fire",Power = "FireBall",Level = 18,Pet = true};session.Store(character);session.SaveChanges();}
using (var session = store.OpenSession()){Characters character = session.Load<Characters>("characters/1-A");Console.WriteLine($"Welcome {character.Name}, " +$"you are level {character.Level} " +$"and are part of the {character.Faction} faction");}
using (var session = store.OpenSession()){var character = session.Load<Characters>("characters/1-A");character.Level = 19;character.Pet = false;session.SaveChanges();}
using (var session = store.OpenSession()){var character = session.Load<Characters>("characters/1-A");session.Delete(character);session.SaveChanges();}

Querying in RavenDB

from Orders where ...
from index "Orders/ByCompany" where ...
from Employees
from Employees where id() = 'employees/1-A'
from Employees
where FirstName = 'Anne'

Setting up multiple nodes

"License.Eula.Accepted": true,"Setup.Mode": "None",
"A node in computer science is a device or a structure, which can be considered as an independent unit. Nodes function within an automated system and communicate with each other." source: Wikipedia


RavenDB and Docker


Useful links and resources:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store