假设我有一个嵌套文档address
的mongoose模式:
var personSchema = new mongoose.Schema({
name: String,
address: {
street: String,
city: String
}
});
var Person = new mongoose.model('Person', personSchema);
现在我可以find
sort
所有人address
var p = new Person();
p.find().sort('address').exec().then(function (result) {
console.log(result);
});
:
address
我发现func keyPressed(sender: AnyObject?) {
let button = sender as UIButton
let title = button.titleForState(.Normal)
(textDocumentProxy as UIKeyInput).insertText(title!)
}
上的排序确实改变了返回结果的顺序,但我无法弄清楚如何。
如何对包含嵌套文档的字段进行排序会影响结果?