查看完整版本: [翻译]RDDB: RESTful Ruby Document-Oriented Database

maninred 2007-11-9 22:55

[翻译]RDDB: RESTful Ruby Document-Oriented Database

[font=Times New Roman, serif][color=Red][size=6][url=http://www.rubyinside.com/rddb-restful-ruby-document-oriented-database-643.html]RDDB[/url][/size][/color][/font][size=6][color=Red][url=http://www.rubyinside.com/rddb-restful-ruby-document-oriented-database-643.html]:[/url][url=http://www.rubyinside.com/rddb-restful-ruby-document-oriented-database-643.html]面向文档的[font=Times New Roman, serif]REST化Ruby[/font][/url][url=http://www.rubyinside.com/rddb-restful-ruby-document-oriented-database-643.html]数据库[/url][/color][/size]
[quote]
[color=#ff0000]原文标题:[/color][font=Times New Roman, serif][color=#ff0000]RDDB: RESTful Ruby Document-Oriented Database[/color][/font]
[color=#ff0000]原文作者:[/color][font=Times New Roman, serif][color=Red]Peter Cooper[/color][/font]
[color=#ff0000]原文地址:[/color][url=http://www.rubyinside.com/rddb-restful-ruby-document-oriented-database-643.html]http://www.rubyinside.com/rddb-restful-ruby-document-oriented-database-643.html[/url]

[color=#ff0000]译者:maninred@Ruby中文社区翻译团队[/color]
[color=#ff0000]译文首发:[url=http://ruby-lang.org.cn/forums/thread-1941-1-1.html]http://ruby-lang.org.cn/forums/thread-1941-1-1.html[/url][/color]

[color=#ff0000]转载请保留本版权信息,违者必究![/color]
[/quote]
[font=Times New Roman, serif]Post by Peter Cooper

[/font][size=3][url=http://rddb.rubyforge.org/][font=Times New Roman, serif]RDDB[/font][/url]是一个面向文档的[/size][font=Times New Roman, serif][size=3]Ruby[/size][/font][size=3]数据库系统,灵感来源于[url=http://couchdb.org/][font=Times New Roman, serif]CouchDB[/font][/url],由[/size][font=Times New Roman, serif][size=3]AnthonyEden[/size][/font][size=3]开发。[/size][size=3]如果你熟悉[/size][font=Times New Roman, serif][size=3]CouchDB[/size][/font][size=3],那从一开始就应该明白整个系统,但如果不是,就要继续读下去。你可以用一个足够简单的方法建立一个数据库并插入文档。

[/size][code]# First create an database object
database = Rddb::Database.new

# Put some documents into it
database << {:name => 'John', :income => 35000}
database << {:name => 'Bob', :income => 40000}[/code][size=4][size=3]

要”查询”数据库,象这样用[/size][/size][font=Times New Roman, serif][size=3]Ruby[/size][/font][size=3]代码块定义一个”[/size][font=Times New Roman, serif][size=3]view“[/size][/font]:

[code]# Create a view that will return the names
database.create_view('names') do |document, args|
  document.name
end

# The result of querying will return an array of names
assert_equal ['John','Bob','Jim'], database.query('names')[/code][size=3]

视图被定义为[/size][font=Times New Roman, serif][size=3]Ruby[/size][/font][size=3]代码块,用来选择你想检索文档和文档中的属性。这一切变得更加强大(和更复杂)而不是这样非常快捷(尤其当你在把额外的[/size][font=Times New Roman, serif][size=3]Ruby[/size][/font][size=3]逻辑加到视图时),查看[url=http://rddb.rubyforge.org/][font=Times New Roman, serif]RDDB[/font]官方网站[/url]可以得到更多示。


[/size]

[[i] 本帖最后由 maninred 于 2007-11-10 12:56 编辑 [/i]]
页: [1]
查看完整版本: [翻译]RDDB: RESTful Ruby Document-Oriented Database