Pouchdb 简明教程

PouchDB - Environment

本章说明如何在系统中下载和安装PouchDB。

This chapter explains how to download and install PouchDB in your system.

Installing PouchDB

为了使用PouchDB,你需要下载文件 .js 并将其包含在你的脚本中。以下是安装PouchDB的步骤。

In order to work with PouchDB, you need to download the file .js file and include it in your script. Following are the steps to install PouchDB.

Step 1

通过单击以下链接访问PouchDB网站的主页 −

Visit the homepage of PouchDB website, by clicking the following link −

pouchdb homepage

Step 2

单击网页右上角的下载按钮,如上图所示。这将在你的系统中下载 PouchDB-5.3.0.min.js

Click the Download button on the top right hand side of the web page as shown in the above screenshot. This will download PouchDB-5.3.0.min.js in your system.

Step 3

PouchDB-5.3.0.min.js 复制并粘贴到你的工作目录,并将其包含在你的JavaScript中,如下面的命令所示。

Copy and paste the PouchDB-5.3.0.min.js to your working directory and include it in your JavaScript as shown in the following command.

<script src = "PouchDB-5.3.0.min.js"></script>

Installing Pouch Using Node.js

你还可以将PouchDB安装为Node.js模块。以下是使用Node.js安装PouchDB的步骤。

You can also install PouchDB as Node.js module. Following are the steps to install PouchDB using Node.js.

Step 1

按照我们 coffee script 教程的安装Node.js部分中提供的步骤安装Node.js。

Install Node.js by following the steps given in the Installing Node.js section of our coffee script tutorial.

Step 2

打开命令提示符并执行以下命令。这将在你的系统中安装PouchDB节点模块。

Open the command prompt and execute the following command. This will install PouchDB node module in your system.

npm install --save PouchDB

Downloading CouchDB

当离线时,PouchDB将数据存储在本地,并像应用程序一样工作。你可以通过连接到兼容的服务器在线访问它。众所周知,PouchDB可以连接到CouchDB,所以,我们也安装CouchDB。以下是安装CouchDB的步骤。

When offline, PouchDB stores data locally and works like an app. You can access it online by connecting with compatible servers. As we know PouchDB can be connected to CouchDB, so, lets install CouchDB too. Following are the steps to install CouchDB.

Step 1

CouchDB的官方网站为 http://couchdb.apache.org 。如果你单击给定的链接,你可以获得CouchDB官方网站的主页,如下面的截图所示。

The official website for CouchDB is http://couchdb.apache.org. If you click the given link, you can get the home page of CouchDB official website as shown in the following screenshot.

download couchdb

Step 2

如果你单击下载按钮,会转到一个页面,其中提供了CouchDB的各种格式的下载链接。以下快照说明了这一点。

If you click on the download button that will lead to a page where the download links of CouchDB in various formats are provided. The following snapshot illustrates the same.

couchdb download links formats

Step 3

选择Windows系统的下载链接,并选择一个提供的镜像来开始下载。

Choose the download link for Windows Systems and select one of the provided mirrors to start your download.

Installing CouchDB

一个Windows可执行 setup-couchdb-1.6.1_R16B02.exe 文件将下载到你的系统中。运行安装文件并继续安装。

A windows executable setup-couchdb-1.6.1_R16B02.exe file will be downloaded on your system. Run the setup file and proceed with the installation.

在成功安装CouchDB到你的系统后,打开安装CouchDB的文件夹,转到bin文件夹,并通过运行名为 couchdb.bat 的脚本文件来启动服务器。

After installing CouchDB in your system successfully, open the folder where CouchDB was installed, go to the bin folder, and start the server by running a script file named couchdb.bat.

安装完成后,访问以下链接打开 CouchDB 的内置 Web 界面: http://127.0.0.1:5984/ 。如果一切顺利,您将获得一个 Web 页面,其中包含以下输出。

After installation, open built-in web interface of CouchDB by visiting the following link − http://127.0.0.1:5984/. If everything goes fine, this will give you a web page, which will have the following output.

{
   "couchdb":"Welcome","uuid":"c8d48ac61bb497f4692b346e0f400d60",
   "version":"1. 6.1",
   "vendor": {
      "version":"1.6.1","name":"The Apache Software Foundation"
   }
}

您可以使用以下 URL 与 CouchDB Web 界面交互:

You can interact with CouchDB web interface by using the following URL −

http://127.0.0.1:5984/_utils/

这会向您展示 Futon 的索引页面,它是 CouchDB 的 Web 界面。

This shows you the index page of Futon, which is the web interface of CouchDB.

web interface