将我的应用程序从 ruby/rails 重写为 javascript/express。 mongodb 能满足我的需求吗?
我的 Rails 3 数据库 schema.rb 如下所示:
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
该数据库的唯一添加内容将通过 openid 与用户相关。 mongoDB 可以处理这个吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,MongoDB 可以处理这种类型的结构。请注意,您可能想要更改数据的结构。您可能需要考虑在
帖子
中嵌入评论
。另请查看
主题
。如果主题名称是唯一的(可能是),那么您可能需要考虑将其设为 MongoDB 中的_id
。如果您要迁移到 Node / MongoDB,您需要查看 mongoosejs.com。这是 MongoDB 的简单 ORM。它可以帮助您对数据进行建模。
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 ofposts
.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.