couchDB数据库根问题
couchdDB dbroot issue
我正在使用couchdb。我是新手。我不知道用dbroot值来代替"db/"。我从coucdb教程中获得了这段代码。提前感谢您的帮助。
//使用命名空间来保护函数和变量名的范围
var poq = {
//Some variables global to the local namespace ("poq")
root: "http://localhost:5984/",
dbroot: "db/",
max_quotes: 6,
//Invoked when the HTML page is first loaded
loadPage: function()
{
var six_latest = poq.root + "poquotes/_design/document/_view/by_year?&limit="
+ poq.max_quotes + "&descending=true&callback=?";
$.getJSON(six_latest, poq.handleMainQuotes);
$('#donewquote').click(function() {
var db_link = poq.dbroot + "poquotes";
var record = {
"type": "quote",
"author": $("#author").val(),
"text": $("#text").val(),
"work": {
"title": $("#title").val(),
"link": $("#link").val(),
"year": parseInt($("#year").val())
}
};
$.ajax({
url : db_link,
data : JSON.stringify(record),
contentType : "application/json",
type : 'POST',
processData : false,
dataType : "json",
success : function(resp) {
alert("New document created: " + JSON.stringify(resp));
}
});
return false;
});
//Set up the collapsible form for adding new quotes
$('#popup').click(function(){
$("#newquote").slideToggle();
});
//Start out with the create quote form collapsed
$("#newquote").slideToggle();
},
//Invoked with the result of the AJAX call to load quote documents
handleMainQuotes: function(json)
{
//Load up to six records, as available
quote_count = Math.min(poq.max_quotes, json["total_rows"])
for (var i=0; i<quote_count; i++) {
var doc = json["rows"][i]["value"]
var year = doc["work"]["year"].toString()
var title = doc["work"]["title"].toString()
var link = doc["work"]["link"].toString()
//Create an HTML snippet from the fields of each quote document
qblock = $("<div class='span4 featured-quote'></div>")
.append("<h2>" + doc["author"] + "</h2>")
.append("<p style='font-size: 80%; height: 8em;'>" + doc["text"] + "</p>")
.append("<p>" + year + "</p>")
.append("<p><a href='" + link + "'>" + title + "</a></p>")
.append("<p><a class='btn' href='#'>View details »</a></p>")
//jQuery's eq selector to find the target div corresponding to the loop index
$('div.featured-quote:eq(' + i.toString() + ')').replaceWith(qblock);
}
},
}
这里的dbroot似乎是数据库的名称。如果你还没有创建数据库,你可以使用:
curl -X PUT http://localhost:5984/mynewdatabase
作为CouchDB的新手,我建议您从《最终指南》开始(http://guide.couchdb.org)
相关文章:
- 使用 jQuery UI 折叠面板显示 couchDB 数据库搜索结果时出现问题
- Ajax发布到PHP脚本,每5秒查询一次MySQL数据库的性能/问题
- 将捕获的图像插入数据库问题(Cordova/SQlite/JavaScript)
- 使用数据库中的图像填充dropzone.js删除图像的问题
- PhoneGap 中的数据库条目出现问题
- 在调用 ajax 和查询数据库时遇到问题
- 通过node-js脚本将文档数组插入mongodb中的数据库时出现问题
- 使用 sequelize ORM 连接到节点上的 Amazon RDS Postgres 数据库.js出现问题
- jquery下拉列表和发布到SQL数据库问题
- 根据类别从数据库中调用不同类型的问题
- 电影数据库“访问控制允许来源”问题
- 使用html、php、js从数据库中删除行时出现问题
- 可排序数据和更新数据库问题
- 在javascript中插入SQLite数据库时出现问题
- 在不处理数据库的情况下解决相同的问题
- couchDB数据库根问题
- 角度拖放保存在数据库中的位置和屏幕大小调整问题
- 与数据库的连接以及与输入处理有关的离子问题
- 通过javascript函数从数据库获取php数据时出现问题
- 在原生脚本应用程序中显示sqlite数据库数据有问题