当前位置: 动力学知识库 > 问答 > 编程问答 >

Rewriting my app from ruby/rails to javascript/express. Will mongodb suit my needs?

问题描述:

My Rails 3 database schema.rb looks like this:

ActiveRecord::Schema.define(:version => 20110504034934) do

create_table "comments", :force => true do |t|

t.string "name"

t.text "content"

t.integer "post_id"

t.datetime "created_at"

t.datetime "updated_at"

t.string "ancestry"

end

add_index "comments", ["ancestry"], :name => "index_comments_on_ancestry"

create_table "posts", :force => true do |t|

t.string "name"

t.string "title"

t.text "content"

t.integer "topic_id"

t.datetime "created_at"

t.datetime "updated_at"

end

create_table "topics", :force => true do |t|

t.string "name"

t.datetime "created_at"

t.datetime "updated_at"

end

end

The only additions to this database would be user-related via openid. Can mongoDB handle this?

网友答案:

Yes, MongoDB can handle this type of structure. Note that you may want to change the structure of your data. You may want to consider embedding comments inside of posts.

Also take a look at topics. If the topic name is unique (it probably is), then you may want to consider making it the _id in MongoDB.

If you're moving to Node / MongoDB, you'll want to check out mongoosejs.com. It's a simple ORM for MongoDB. It may help you model the data.

分享给朋友:
您可能感兴趣的文章:
随机阅读: