Create a database and add documents
Watch this short video to see how to create a database and add documents.
Here are some other ways to load data:
- Use the
_bulk_docsendpoint to bulk load JSON documents. Visit the HTTP API page and watch the Execute common API commands video along with Tutorial 4 to try out the _bulk_docs endpoint, or check out the Bulk operations documentation.
- Use couchimport to load data from a spreadsheet. (See more import tools.)
- Replicate a database. Learn how on the Replication page.
Try the tutorials
Now that you’ve seen how to create a database and add documents, try it for yourself! In these tutorials, you’ll create a database and work with documents in the database.
If you haven’t created a Cloudant account yet, complete the steps on the Get Started page.
Tutorial 1: Create a Database and add documents
- From the Cloudant dashboard, at the upper right corner, click Create Database.
- Type businesscard for the database name, select Non-partitioned, and click OK. The database name should contain only lowercase alphanumeric characters and no spaces.
- The database might take a few seconds to be created. You should then be on the database tab in the Cloudant Dashboard. Click the + sign next to All Documents, and select New Doc to create a new document.
- The dashboard includes an easy-to-use JSON editor that helps ensure the documents use the correct JSON syntax. A JSON document includes a set of key value pairs: a name and its value. When you create a document, Cloudant automatically generates a unique document identifier, or you can provide your own. The value of the id key is how the database system identifies each document and must be unique in each database. Copy/paste the following text into the editor:
- Cloudant allows you to use a flexible schema. Each document can use the same schema or use a unique schema. The values in a document can contain numbers, strings, nested objects, arrays, or Boolean data. Your document should look similar to the following image:
- Click Create Document. Then open the document to notice that Cloudant populated the _rev field.
- Click Cancel to go back to viewing all the documents in the database.
- To add another document to the database, you can click the + sign next to All Documents again.
- Create another business card style document using the same format as the previous document containing an id, name, title, and address of your choosing.
- Click Create Document.
"name": "Bob Smith",
"street": "123 Main St",
"skills": [ "Cloudant", "NoSQL","JSON"
Tutorial 2: Update a document
- Now observe what happens to the _rev field when a document is updated. Edit the document you just created, add a phone number field, and click Save Changes.
In the following example, notice that the _rev integer is incremented by one, and hash of the document body is now changed.
Tutorial 3: Clone a document
- With the document still open, click Clone Document in the top right corner.
- Provide a unique ID for the cloned document, and click Clone Document.
- Change the name, title, address, and phone number for this new cloned document.
- Click Save Changes.
Tutorial 4: Delete a document
- From the All Documents view, select one of the documents.
- In the header, click the Trash icon.
- When asked to confirm whether you want to delete the document, click OK to delete it.
Now watch this short video to see how to set permissions at the database level if using Cloudant legacy authentication, and how to set instance-level permissions using IAM authentication and resource groups.
Replicate a sample database
This video shows you how to replicate a sample database from the Cloudant Examples account.