RavenDB 2.x  Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Time for action – creating your first document

You will learn to create some new documents using the Management Studio and add them to the Orders database.

  1. If it is not running, launch the RavenDB server.
    Tip

    To open the Management Studio manually in your browser, go to this URL: http://localhost:8080/raven/studio.html.

  2. Ensure that the current database is Orders, otherwise, click on the Databases hyperlink button to display the Databases screen and select the Orders database.
  3. In the Management Studio toolbar, click on the arrow near the New button and select New Document.
  4. Enter the document ID Orders/A179854 and enter the following document data values:
    {
    "CustomerId":"A54309",
    "Item":"Paper Set",
    "OrderDate":"11/17/2011",
    "UnitCost":25.99,
    "Units":5
    }
  5. After that, click on the Save button to insert the document into the Orders database.
  6. Repeat the steps 3 and 4 to add new documents to the Orders database using the following data:

What just happened?

You just populated the Orders database directly by using the Management Studio editors with five new documents.

In steps 1 to 3, we created the Orders databases and in steps 4 to 6, we added five new documents to the database.

Note

If you save a document without providing the document ID, RavenDB will create a new Guid and assign it to the document as its unique ID.