Page tree
Skip to end of metadata
Go to start of metadata

21/05/2016 - v2.1.0 documentation will be ready soon, some of the information here will be out of date

 

Often when working with no-SQL we face recurring problems:

  1. Modelling data to fit your required structures while not impacting the domain model
  2. Repeatable data patterns that are usually not available by default in client libraries
  3. Overwhelmingly difficult to use libraries aiming to be extensible, flexible and powerful, but never quite managing any of them

NDescribe aims to fix all of these issues with a simple fluent API that is also easily extensible and as powerful as you need it when you need it, rather than forcing you to consume interfaces that have every feature every time you want to store a document. At the same time it aims to allow easy pattern modelling with no real knowledge of the underlying implementation.

Getting hold of NDescribe

Currently the best way of getting NDescribe is via Nuget. There are three packages:

  • NDescribe-Core - the core assemblies without any data bridges included. This is intended for users who want to connect NDescribe up to a different data bridge than the standard Couchbase or InMemory ones
  • NDescribe-Couchbase - the core assemblies and the Couchbase data bridge. This should be the default package that you install if you want to use NDescribe to connect to Couchbase
  • NDescribe-InMemory - the core assemblies and the InMemory data bridge. This is currently used for testing, but it could be used as a simple caching solution.

NDescribe is fully open source under the Apache 2.0 license and can be found here.

Currently supports the following framework versions:

  • 4.5
  • 4.5.1
  • 4.5.2
  • 4.6
  • 4.6.1

The simplest example...

            DataContext context = new DataContext("dataLocation");
            context
                .Define<Foo>(foo => $"FooKey::{foo.Name}").Defined()
                .Define<Bar>(bar => $"{bar.Title}::{bar.Description}").Defined();

            var dataSession = new DataSessionFactory().CreateSession(new[] {context});
            DataResult storeDocument = dataSession.Save(new Foo { Name = "blah"});
			DataRetrievalResult<Foo> readDocument = dataSession.Read(new Foo {Name = "blah"});

We create a new DataContext which represents a single data location (in SQL terms this is a database, for something like Couchbase it's a bucket).

Using that context we define the data model for two of our domain objects - Foo and Bar. We define Foo's key as FooKey::<whatever Foo's name is> and Bar's key as <whatever Bar's title is>::<whatever Bar's description is>.

The Defined on the end of each definition finishes the definition (this is important in later examples, but not for now).

Once we've defined our context, we create a new DataSession based on our contexts, store a Foo document after setting its Name property, and then retrieve a Foo document based on the same name.

For clarification, there's two storage methods - Save and Create.

  • Save - always inserts or overwrites (equivalent to an upsert)
  • Create - only ever inserts. If the document exists already it fails

Check the other pages for different examples.

  • No labels