【发布时间】:2015-04-17 10:03:01
【问题描述】:
定义复合索引:
db.collection.ensureIndex( { orderDate: 1, zipcode: -1 } )
我突然恍然大悟:JS 对象的字段是有序的吗? 是否有一个隐含的假设,即 orderDate 是第一位的?我很惊讶它没有使用数组。
对于猫鼬,我们使用:
schema.index({a:1, b:1})
我们如何确保这个对象按照代码中指定的顺序传输到 mongo 服务器?
这篇文章说字段没有排序。 Does JavaScript Guarantee Object Property Order?
Is it acceptable style for Node.js libraries to rely on object key order?
【问题讨论】:
标签: javascript node.js mongodb indexing