【发布时间】:2016-01-02 17:51:53
【问题描述】:
我在 Mongoose 中使用 Node.js 和 MongoDB。 我以 Node.js 的形式连接到 Mongoose,
db = mongoose.connect('mongodb://localhost/my_database_name')
如何在node.js中配置一次到create index集合?
我的App的目录结构是,基于this tutorial:
HTML views/
Angular.js public/javascript/
Express.js routes/
Node.js app.js
Mongoose js models/, set up in app.js
Mongo db set up in app.js
指导我如何在 MongoDB 集合表单 Node.js 上提供索引。
【问题讨论】:
-
使用猫鼬你通常会想要define the indexes with the schema。
-
您好,卡尔·格罗纳,谢谢。您还可以检查我在下面的答案中写的关于将复合索引行放入 app.js 文件中的内容是否正确?
标签: node.js mongodb mongoose mean-stack