jrusbatch / compilify

A web-based compiler for C# and VB.NET, powered by the Roslyn Project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace MongoDB with RavenDB

jrusbatch opened this issue · comments

RavenDB offers a cleaner API and indexing features that can be implemented with little additional work. Due to the significance of the changes being made to the data model in order to accomodate other new features, this is a good time to switch.

There are two ways to model the idea of a project in RavenDB. I'm not sure which one to pick but I think I'm leaning towards the second.

First Method:

public class Project {
    public Id { get; set }
    public IList<Document> Documents { get;set; }
}

Second Method:

public class Project {
    public string Id { get;set; }
}

public class Document {
    public string Id { get;set; }
    public string ProjectId { get; set; }
}

The reason I am leaning towards the second is because you can update individual documents from the client a lot easier, but then you can use a projection to return the full project.

Projection [ map / reduce]

 map => documents => from d in documents
                                   select new {  d.ProjectId, document = d }

 reduce => results => from r in results
                                group r by r.ProjectId into g
                                select new  Project { Id = g.Key, Documents = g.Select(x => x.document) }

What do you think?

The documents have little meaning by themselves. Only basic lexical and syntactical analysis can be performed on a standalone document. The entire project that it belongs to is needed to perform semantic analysis and code navigation. I would favor just loading the entire project with all of its documents so that we can perform as much validation as we can after each change.