
上QQ阅读APP看书,第一时间看更新
Time for action — creating a document in Futon
We've gone through the updating of existing documents. Let's create a document from scratch in Futon.
- Go to the database overview by clicking on the database name,
test-db
, in the header. - Click on New Document.
- A blank document is created and ready for us to put in new fields. Notice that the
_id
is already set for us (but we can change it if we want). - Click on Add Field to create a new field, and call it
location
. - Double-click on the value right next to the label that says null, and enter in your current location.
- Click on Add Field to create a new field, and call it
name
. - Double-click on the value right next to the label that says
null
, and enter in your name. - Click on Save Document at the top of the page.
- The document has been saved. Notice that it now has a
_rev
value set.
What just happened?
You just used Futon to create a document from scratch. When the document was first created, CouchDB created a unique ID for you to set it as the value of the _id
field. Next, you added the name
field and inputted your name as its value. Finally, you saved it to create a new document. We've talked about how documents can have completely different fields, but this is the first time we've actually done it!