Tag: mongoose robomongo

MongoDB RegExp不一致

这里是testing用例: db.test.insert({ name: "john"}); db.test.insert({ name: "donny"}); db.test.insert({ name: "lenny"}); db.test.find({ name: { $regex: /^((?!nn)[\s\S])*$/}}); //works fine, returns only john db.test.find({ name: { $regex: new RegExp("/^((?!nn)[\s\S])*$/")}}); //returns nothing 正则expression式应该返回不包含“nn”的对象,但在使用RegExp对象时不起作用。 我使用Robomongotesting了这个。 任何想法为什么?

Mongoose模式字段在MongoDB中是反向sorting的

只是想知道为什么在MongoDB GUI中查看的字段与在Mongoose中的schema的定义相比较? 这是架构: 这里是插入function: 这就是我在Robomongo看到的: 我的问题是为什么字段的sorting方式与我在schema中定义的方式相比?