RAVENDB official website document Translation series first

Source: Internet
Author: User

This series of articles is mainly translated from RavenDB official documents, some places have been cut, some content is integrated together. Welcome to a friend who needs to read. After all, is Chinese reading more cordial? Let's get down to the chase.

Sail

GetRavenDB

RavenDB can be obtained through NuGet , or it can be downloaded directly from the RavenDB website .

First understand the contents of the compressed package, you can better choose according to the needs.

l backup– contains the raven.backup tool for backup

l The bundles– contains all non-built-in plugins, such as authentication and encryption.

l client– contains all . NET Client Libraries for development

l server– all server files (including configuration files such as Raven.Server.exe.config)

l smuggler– contains tools for importing and exporting data between servers

l Web – All files for IIS Development

The official website download page also provides the installation package, and gives the installation package installation document, the illustrations are more understandable, here is not translated. The installation package uses a document portal .

Start the server

to begin to experience RavenDB, a running RavenDB service is not limited. a Start.cmd file is included in the downloaded package , and running this file starts a server (debug mode) in the console mode, which is suitable for development purposes or simple attempts to perform various functions rather than the publisher. After the service is running, you can access the administrative tools through http://localhost:port/. The default port number is 8080, and when 8080 is occupied, the next available port number is selected.

Tips

Please refer to this article if you need to install RAVENDB as a service. Ravendb can also be run in IIS or embedded in an executable program.

Client

All. NET clients can be found in the client directory of the downloaded compressed package. After you reference the appropriate assembly in your project, you can access all the classes under the Raven.* namespace, where Documentstore is the most interesting. This is the portal to your app's access to RAVENDB, which establishes and maintains a connection between your app and the server. Please refer to several articles about Documentstore:

    • What is the document store?

    • Create a document Store

    • Set the default database

Tips

It is important to note that Documentstore is a heavyweight object, and each program should have only one Documentstore instance (singleton)

There are two ways to manipulate data using Documentstore, the first (and recommended) way is through the session, and the second is that Commands,commands is a way to manipulate data at the bottom, and should only be used if there is a need. Both the session and the commands both contain synchronous and asynchronous methods.

You can use the articles listed below to find out more:

    • What is a session and how does it work? and open a session

    • What is commands?

Example

Before proceeding, I would like to point out that most of the articles here are in the Northwind database. Here you can see more details on how to deploy this database.

Principles and some examples

RAVENDB is a document database, and all stored objects are referred to as documents . Each document is stored in JSON format, which contains a key,data and metadata that identify the document. Metadata contains a variety of information describing the document, such as the modified date or the layout of the collection.

Create Documentstore, open session, store and load entities

The following example shows how to create a Documentstore, open a session, store, and load some entities.

using  (idocumentstore store = new documentstore{ url =  "/http localhost:8080/", // server url defaultdatabase = "  //  "Northwind" Default database}) { store. Initialize ();  // initializes document store, by connecting to server  and downloading various configurations using  (idocumentsession session  = store. Opensession ())  // opens a session that will work in context  of  ' DefaultDatabase '  {  employee employee = new employee  {    FirstName =  "John",   lastname =  "Doe"   };   session. Store (employee);  // stores employee in session, assigning it to a  collection  ' Employees ' &NBSP;&NBSP;STRING&NBSP;EMPLOYEEID&NBsp;= employee. Id; // session.store will assign id to employee, if it is  not set  session. SaveChanges (); // sends all changes to server  // session  Implements unit of work pattern,  // therefore employee instance  would be the same and no server call will be made   employee loadedemployee = session. Load<employee> (employeeId);   assert.equal (employee, loadedemployee);  }

Inquire

To implement a query, you must use an index. In short, an index is a server-side function that defines which fields (and what values) are used to find in a document. The entire indexing process is performed asynchronously, and doing so will result in a quick response, even if a large amount of data is updated, but the index is not necessarily up-to-date in this implementation. Before proceeding, it is recommended to read the following article:

    • What is an index?

    • Create and deploy an index

    • Index base

    • Map Index

This example assumes that your database contains the Northwind sample data. If you don't know how to deploy the sample data, check out this article.

 <summary>/// All _ in index class names will be  converted to //// it means that employees_byfirstnameandlastname will  be employees/byfirstnameandlastname/// when deployed to server/// ///  abstractindexcreationtask is a helper class that gives you  Strongly-typed syntax/// for creating indexes/// </summary>public class  employees_byfirstnameandlastname : abstractindexcreationtask<employee>{ public  employees_byfirstnameandlastname ()  {  // this is a simple  (MAP)  index linq-flavored mapping function  // that enables searching  of Employees by  // FirstName, LastName  (Or both)   map  = employees => from employee in employees         select  new       {        firstname =  employee. Firstname,        lastname = employee. lastname       }; }}

Some bits and pieces about the document

The documentation is divided into the following sections:

    • In the Indexes section, you can find all the indexes and queries related to the theory.

    • The Transformers section contains information about server-side conversion functions that are used to form query results.

    • The Client API section, which contains API references and related basic examples for most of the functions in the clients.

    • The server section contains information about the management, maintenance, configuration, installation, and commissioning of servers.

    • The Studio section lets you know what you can do with studio

Example

The available sample programs are listed below:

    • MVC Starter Kit

Walkthrough Server

If you are interested in this, please check this article.

RAVENDB official website document Translation series first

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.