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.
精彩评论