Reputation: 649
Summary: How to sort all items according to registration date. When I tried it gives me no output, My code is shown below
Code sample:
abcdschema.statics.fetchall = function fetchall(cb) {
var id_temp='abcd';
this.query('id').contains(id_temp).where('regDate').ascending(function(err,res){
console.log(err,res);
})
}
Schema
id: {
type: String,
required: true,
hashKey: true
},
name: {
type: String,
required: true,
rangeKey: true
},
regDate: { type: Date, required: true, default: Date.now },
activeFlag: { type: Boolean, default: true }
Environment:
Upvotes: 1
Views: 1591
Reputation: 20496
Few issues here.
Query.exec()
to pass in your callback function instead of passing it into the ascending function.Query.eq()
for your hash key.index
property on your schema, and use the rangeKey
property to sort using that. See this line and this line in the tests for more details on how to do a descending query.Upvotes: 1