Introduction to CouchDB with .NET part 15: show functions in design documents

Introduction

In the previous post we took a look at lists in CouchDB design documents. Lists operate in conjunction with views. A list function has access to the output of a view and can transform it into a different data set. Lists do not change the underlying data at all, they are a type of extension to views. A list can output simple JSON or advanced HTML for fancy reports. We have access to the HTTP request object within the list function. The output of a list function can thus depend on stuff like query parameters, request headers, cookies etc.

In this post we’ll look at another function type in design documents called show functions.

Read more of this post

Advertisement

Introduction to CouchDB with .NET part 14: list functions in design documents

Introduction

In the previous post we looked at validation functions in CouchDB design documents. A validation function is used for data validation when inserting a new document or updating an existing one. It is called automatically upon an insert or update operation. We saw how to write a function that checks particular properties in the incoming document and throws an exception if it violates some business rules. We can also check whether the user executing the modification has a certain username or is in a user role, i.e. whether they are authorised to perform the action.

In this post we’ll look at lists in design documents.

Read more of this post

Introduction to CouchDB with .NET part 13: validation functions in design documents

Introduction

In the previous post we saw some additional examples of MapReduce functions in CouchDB view design documents. First we investigated the built-in _sum reducer which – as its name applies – can be used to sum up numerical values of the keys from the map phase. The reducer can sum up integers, arrays of integers and objects whose properties are integers. Then we looked at how grouping works and then continued with a brief discussion of custom reducers. We can write our own reducers in JavaScript but we need to make sure that we always return a single value. If we need multiple values from a reducer then can wrap them in a JSON object and return that. Also, the usage of the rereduce parameter is confusing at first and we might only need it in large data sets.

In this post we’ll take a look at another type of functions in design documents, namely validation functions.

Read more of this post

Introduction to CouchDB with .NET part 12: more MapReduce examples

Introduction

In the previous post we first saw how to insert and update design documents via the HTTP API. It is not very different from the equivalent operations on “normal” data documents. However, we need to consider the keywords in a design documents such as “views”, “map” and “reduce”. We also saw how to select compound keys and values in the map function of the view index. Compound keys are very helpful when executing more complex queries such as “select all users above the age 20 and an address in Washington”. We went through a number of examples about limiting the range of the result set using the startkey and endkey query parameters.

In this post we’ll continue where we left off previously and go through more MapReduce examples.

Read more of this post

Introduction to CouchDB with .NET part 11: various MapReduce examples

Introduction

In the previous post we continued exploring view design documents in CouchDB. We first saw how to filter the documents that will be considered in the map phase. We then examined various simple operations on the key returned by the mapping. Our first reducer example included the usage of the built-in _count function for a simple count aggregation. Lastly we mentioned the usage of the stale query parameter to tell CouchDB how to handle the updating of the view indexes.

In this post we’ll continue looking at querying through views and MapReduce functions in CouchDB.

Read more of this post

Introduction to CouchDB with .NET part 10: view design documents cont’d

Introduction

In theprevious post we started looking into a large and relatively complex topic within CouchDB namely design documents. Design documents are JSON documents like the data documents we’ve looked at so far but they have a special purpose. They use JavaScript for their logic. The JS functions are embedded in the JSON document which has sections for each type of role a design document can play: view, update, show/list, validation. We started discussing the view design documents that play an important role in querying a CouchDB database. We also introduced the idea of MapReduce that is heavily used in view-based queries.

In this post we’ll continue where we left off in the previous part and continue looking at how view design documents work. We’ll keep using the children database we created previously.

Read more of this post

Introduction to CouchDB with .NET part 9: starting with view design documents

Introduction

In the previous post we looked at data replication in CouchDB. Data replication means that the documents of a source database are copied over to the target database. At the end of the replication process the source and target databases should have the exact same set of documents where even the revision IDs are the same. Data replication is a means of creating backups and archives. It is also great if we need to test a function on real-life production data. We can run the tests on the replicated data set as much as we want without any effect on the production system. Data replication can be a one-off event or a continuous flow of data synchronisation.

In this post we’ll start looking into a large topic within CouchDB, namely design documents.

Read more of this post

Introduction to CouchDB with .NET part 8: data replication

Introduction

In the previous post we saw how to view changes made to a database. The _changes API endpoint returns a JSON with the list of changes. There are various filter functions to view only certain document IDs or include the properties of the document in the response.

In this post we’ll take a look at data replication between two databases.

Read more of this post

Introduction to CouchDB with .NET part 7: viewing changes made in the database

Introduction

In the previous post we looked at batch insertions and updates in CouchDB. Batch operations are very useful if we intend to insert or update multiple documents at once. We can mix insertions, updates and deletions in the same batch operation. The individual modifications in the batch are treated in isolation. This implies that if one modification fails then it won’t affect the others. In other words batch operations are non-atomic in CouchDB.

In this post we’ll look at a way to check what changes have been made to a CouchDB database.

Read more of this post

Introduction to CouchDB with .NET part 6: batch updates and insertions

Introduction

In the previous post we looked at the CouchDB concurrency implementation and the notion of eventual consistency. Concurrency in a database means that multiple threads might want to access and modify the same data record at the same time. CouchDB solves the concurrency problem by a mechanism called Multi-Version Concurrency Control MVCC. With MVCC CouchDB keeps the various revisions of the same document. If a thread wants to read the document while it is being updated then the reading thread will get the most recent complete copy of the document. The caller will in such a case get an outdated revision of the document. However, a subsequent request will then get the updated copy. This scenario is called eventual consistency. CouchDB reaches high availability due to the absence of data locks and sacrifices data consistency to some degree.

In this post we’ll look at batch updates and insertions.

Read more of this post

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

Bite-size insight on Cyber Security for the not too technical.

%d bloggers like this: