按照此处的文档http://dev.yathit.com/ydn-db/getting-started.html的示例,“排序”下的第一个示例。
我的代码:
var schema = {
stores: [
{
name: "authors",
keyPath: "id",
indexes: [
{ keyPath: "born" }
]
}
]
};
var db = new ydn.db.Storage("library", schema);
db.put("authors", [{ id: "111", born: "zzz" }, { id: "555", born: "bbb" }, { id: "999", born: "aaa" }]).done(function() {
// query with default ordering
db.values("authors").done(function(r) {
console.log("A list of objects as expected", r);
});
// query by ordered by "born" field
db.values(new ydn.db.Cursors("authors", "born", null, false)).done(function(r) {
console.log("This is a list of ids, not objects", r);
});
});
将查询从默认排序更改为按特定列排序似乎会将其行为从返回对象列表更改为仅返回 ID 列表。难道我做错了什么?如何获取对象列表?