1
以下是文档http://dev.yathit.com/ydn-db/getting-started.html中的示例,这是“排序”下的第一个示例。如何检索ydn-db中的对象的排序列表?
我的代码:
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列表。难道我做错了什么?如何获取对象列表?
感谢您的实质性答案。第三个工作正常,第二个也是,但我不得不将其更改为 var limit = 999; db.values(“authors”,“born”,null,limit).done(...); 否则我得到“ydn.error.ArgumentException:限制必须是一个数字。” –